@@ -435,7 +435,10 @@ private Channel verifyChannelPipeline(Channel channel, String scheme) throws IOE
435
435
return channel ;
436
436
}
437
437
438
- protected final <T > void writeRequest (final Channel channel , final AsyncHttpClientConfig config , final NettyResponseFuture <T > future , final HttpRequest nettyRequest ) {
438
+ protected final <T > void writeRequest (final Channel channel , final AsyncHttpClientConfig config , final NettyResponseFuture <T > future ) {
439
+
440
+ HttpRequest nettyRequest = future .getNettyRequest ();
441
+
439
442
try {
440
443
/**
441
444
* If the channel is dead because it was pooled and the remote server decided to close it, we just let it go and the closeChannel do it's work.
@@ -445,7 +448,7 @@ protected final <T> void writeRequest(final Channel channel, final AsyncHttpClie
445
448
}
446
449
447
450
Body body = null ;
448
- if (!future . getNettyRequest () .getMethod ().equals (HttpMethod .CONNECT )) {
451
+ if (!nettyRequest .getMethod ().equals (HttpMethod .CONNECT )) {
449
452
BodyGenerator bg = future .getRequest ().getBodyGenerator ();
450
453
if (bg != null ) {
451
454
// Netty issue with chunking.
@@ -472,8 +475,8 @@ protected final <T> void writeRequest(final Channel channel, final AsyncHttpClie
472
475
if (future .getAsyncHandler () instanceof TransferCompletionHandler ) {
473
476
474
477
FluentCaseInsensitiveStringsMap h = new FluentCaseInsensitiveStringsMap ();
475
- for (String s : future . getNettyRequest () .getHeaderNames ()) {
476
- for (String header : future . getNettyRequest () .getHeaders (s )) {
478
+ for (String s : nettyRequest .getHeaderNames ()) {
479
+ for (String header : nettyRequest .getHeaders (s )) {
477
480
h .add (s , header );
478
481
}
479
482
}
@@ -497,7 +500,7 @@ protected final <T> void writeRequest(final Channel channel, final AsyncHttpClie
497
500
}
498
501
499
502
if (future .getAndSetWriteBody (true )) {
500
- if (!future . getNettyRequest () .getMethod ().equals (HttpMethod .CONNECT )) {
503
+ if (!nettyRequest .getMethod ().equals (HttpMethod .CONNECT )) {
501
504
502
505
if (future .getRequest ().getFile () != null ) {
503
506
final File file = future .getRequest ().getFile ();
@@ -538,8 +541,8 @@ public void operationComplete(ChannelFuture cf) {
538
541
* TODO: AHC-78: SSL + zero copy isn't supported by the MultiPart class and pretty complex to implements.
539
542
*/
540
543
if (future .getRequest ().getParts () != null ) {
541
- String contentType = future . getNettyRequest () .getHeader (HttpHeaders .Names .CONTENT_TYPE );
542
- String length = future . getNettyRequest () .getHeader (HttpHeaders .Names .CONTENT_LENGTH );
544
+ String contentType = nettyRequest .getHeader (HttpHeaders .Names .CONTENT_TYPE );
545
+ String length = nettyRequest .getHeader (HttpHeaders .Names .CONTENT_LENGTH );
543
546
body = new MultipartBody (future .getRequest ().getParts (), contentType , length );
544
547
}
545
548
@@ -953,7 +956,7 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand
953
956
channel .getPipeline ().getContext (NettyAsyncHttpProvider .class ).setAttachment (f );
954
957
955
958
try {
956
- writeRequest (channel , config , f , nettyRequest );
959
+ writeRequest (channel , config , f );
957
960
} catch (Exception ex ) {
958
961
log .debug ("writeRequest failure" , ex );
959
962
if (useSSl && ex .getMessage () != null && ex .getMessage ().contains ("SSLEngine" )) {
@@ -2144,7 +2147,7 @@ public Object call() throws Exception {
2144
2147
if (statusCode == 100 ) {
2145
2148
future .getAndSetWriteHeaders (false );
2146
2149
future .getAndSetWriteBody (true );
2147
- writeRequest (ctx .getChannel (), config , future , nettyRequest );
2150
+ writeRequest (ctx .getChannel (), config , future );
2148
2151
return ;
2149
2152
}
2150
2153
0 commit comments