@@ -204,7 +204,7 @@ public void configureBootstraps(NettyRequestSender requestSender, AtomicBoolean
204
204
public ChannelPipeline getPipeline () throws Exception {
205
205
ChannelPipeline pipeline = pipeline ();
206
206
pipeline .addLast (HTTP_HANDLER , newHttpClientCodec ());
207
- pipeline .addLast (INFLATER_HANDLER , new HttpContentDecompressor ());
207
+ pipeline .addLast (INFLATER_HANDLER , newHttpContentDecompressor ());
208
208
pipeline .addLast (CHUNKED_WRITER_HANDLER , new ChunkedWriteHandler ());
209
209
pipeline .addLast (HTTP_PROCESSOR , httpProcessor );
210
210
@@ -235,7 +235,7 @@ public ChannelPipeline getPipeline() throws Exception {
235
235
ChannelPipeline pipeline = pipeline ();
236
236
pipeline .addLast (SSL_HANDLER , new SslInitializer (ChannelManager .this ));
237
237
pipeline .addLast (HTTP_HANDLER , newHttpClientCodec ());
238
- pipeline .addLast (INFLATER_HANDLER , new HttpContentDecompressor ());
238
+ pipeline .addLast (INFLATER_HANDLER , newHttpContentDecompressor ());
239
239
pipeline .addLast (CHUNKED_WRITER_HANDLER , new ChunkedWriteHandler ());
240
240
pipeline .addLast (HTTP_PROCESSOR , httpProcessor );
241
241
@@ -262,6 +262,18 @@ public ChannelPipeline getPipeline() throws Exception {
262
262
});
263
263
}
264
264
265
+ private HttpContentDecompressor newHttpContentDecompressor () {
266
+ if (nettyConfig .isKeepEncodingHeader ())
267
+ return new HttpContentDecompressor () {
268
+ @ Override
269
+ protected String getTargetContentEncoding (String contentEncoding ) throws Exception {
270
+ return contentEncoding ;
271
+ }
272
+ };
273
+ else
274
+ return new HttpContentDecompressor ();
275
+ }
276
+
265
277
public final void tryToOfferChannelToPool (Channel channel , boolean keepAlive , String partition ) {
266
278
if (channel .isConnected () && keepAlive && channel .isReadable ()) {
267
279
LOGGER .debug ("Adding key: {} for channel {}" , partition , channel );
@@ -388,14 +400,14 @@ public static SslHandler getSslHandler(ChannelPipeline pipeline) {
388
400
public static boolean isSslHandlerConfigured (ChannelPipeline pipeline ) {
389
401
return pipeline .get (SSL_HANDLER ) != null ;
390
402
}
391
-
403
+
392
404
public void upgradeProtocol (ChannelPipeline pipeline , String scheme , String host , int port ) throws IOException ,
393
405
GeneralSecurityException {
394
406
if (pipeline .get (HTTP_HANDLER ) != null )
395
407
pipeline .remove (HTTP_HANDLER );
396
408
397
409
if (isSecure (scheme ))
398
- if (isSslHandlerConfigured (pipeline )){
410
+ if (isSslHandlerConfigured (pipeline )) {
399
411
pipeline .addAfter (SSL_HANDLER , HTTP_HANDLER , newHttpClientCodec ());
400
412
} else {
401
413
pipeline .addFirst (HTTP_HANDLER , newHttpClientCodec ());
@@ -434,7 +446,8 @@ public ClientBootstrap getBootstrap(String scheme, boolean useProxy, boolean use
434
446
public void upgradePipelineForWebSockets (ChannelPipeline pipeline ) {
435
447
pipeline .addAfter (HTTP_HANDLER , WS_ENCODER_HANDLER , new WebSocket08FrameEncoder (true ));
436
448
pipeline .remove (HTTP_HANDLER );
437
- pipeline .addBefore (WS_PROCESSOR , WS_DECODER_HANDLER , new WebSocket08FrameDecoder (false , false , nettyConfig .getWebSocketMaxFrameSize ()));
449
+ pipeline .addBefore (WS_PROCESSOR , WS_DECODER_HANDLER ,
450
+ new WebSocket08FrameDecoder (false , false , nettyConfig .getWebSocketMaxFrameSize ()));
438
451
pipeline .addAfter (WS_DECODER_HANDLER , WS_FRAME_AGGREGATOR , new WebSocketFrameAggregator (nettyConfig .getWebSocketMaxBufferSize ()));
439
452
}
440
453
@@ -455,7 +468,7 @@ public void drainChannel(final Channel channel, final NettyResponseFuture<?> fut
455
468
456
469
public void flushPartition (String partitionId ) {
457
470
channelPool .flushPartition (partitionId );
458
- }
471
+ }
459
472
460
473
public void flushPartitions (ChannelPoolPartitionSelector selector ) {
461
474
channelPool .flushPartitions (selector );
0 commit comments