@@ -428,8 +428,10 @@ protected final <T> void writeRequest(final Channel channel, final AsyncHttpClie
428
428
} else {
429
429
nettyRequest .setHeader (HttpHeaders .Names .TRANSFER_ENCODING , HttpHeaders .Values .CHUNKED );
430
430
}
431
- } else {
432
- body = null ;
431
+ } else if (future .getRequest ().getParts () != null ) {
432
+ String contentType = nettyRequest .getHeader (HttpHeaders .Names .CONTENT_TYPE );
433
+ String length = nettyRequest .getHeader (HttpHeaders .Names .CONTENT_LENGTH );
434
+ body = new MultipartBody (future .getRequest ().getParts (), contentType , length );
433
435
}
434
436
}
435
437
@@ -473,7 +475,7 @@ protected final <T> void writeRequest(final Channel channel, final AsyncHttpClie
473
475
474
476
ChannelFuture writeFuture ;
475
477
if (channel .getPipeline ().get (SslHandler .class ) != null ) {
476
- writeFuture = channel .write (new ChunkedFile (raf , 0 , fileLength , 8192 ));
478
+ writeFuture = channel .write (new ChunkedFile (raf , 0 , fileLength , MAX_BUFFERED_BYTES ));
477
479
} else {
478
480
final FileRegion region = new OptimizedFileRegion (raf , 0 , fileLength );
479
481
writeFuture = channel .write (region );
@@ -497,15 +499,7 @@ public void operationComplete(ChannelFuture cf) {
497
499
}
498
500
throw ex ;
499
501
}
500
- } else if (body != null || future .getRequest ().getParts () != null ) {
501
- /**
502
- * TODO: AHC-78: SSL + zero copy isn't supported by the MultiPart class and pretty complex to implements.
503
- */
504
- if (future .getRequest ().getParts () != null ) {
505
- String contentType = future .getNettyRequest ().getHeader (HttpHeaders .Names .CONTENT_TYPE );
506
- String length = future .getNettyRequest ().getHeader (HttpHeaders .Names .CONTENT_LENGTH );
507
- body = new MultipartBody (future .getRequest ().getParts (), contentType , length );
508
- }
502
+ } else if (body != null ) {
509
503
510
504
ChannelFuture writeFuture ;
511
505
if (channel .getPipeline ().get (SslHandler .class ) == null && (body instanceof RandomAccessBody )) {
@@ -792,28 +786,13 @@ else if (uri.getRawQuery() != null)
792
786
}
793
787
794
788
} else if (request .getParts () != null ) {
795
- int length = computeAndSetContentLength (request , nettyRequest );
796
-
797
- if (length == -1 ) {
798
- length = MAX_BUFFERED_BYTES ;
799
- }
800
-
801
789
MultipartRequestEntity mre = AsyncHttpProviderUtils .createMultipartRequestEntity (request .getParts (), request .getHeaders ());
802
790
803
791
nettyRequest .setHeader (HttpHeaders .Names .CONTENT_TYPE , mre .getContentType ());
804
792
nettyRequest .setHeader (HttpHeaders .Names .CONTENT_LENGTH , String .valueOf (mre .getContentLength ()));
805
793
806
- /**
807
- * TODO: AHC-78: SSL + zero copy isn't supported by the MultiPart class and pretty complex to implements.
808
- */
809
-
810
- if (isSecure (uri )) {
811
- ChannelBuffer b = ChannelBuffers .dynamicBuffer (length );
812
- mre .writeRequest (new ChannelBufferOutputStream (b ));
813
- nettyRequest .setContent (b );
814
- }
815
794
} else if (request .getEntityWriter () != null ) {
816
- int length = computeAndSetContentLength (request , nettyRequest );
795
+ int length = getPredefinedContentLength (request , nettyRequest );
817
796
818
797
if (length == -1 ) {
819
798
length = MAX_BUFFERED_BYTES ;
@@ -1580,15 +1559,12 @@ protected static boolean abortOnWriteCloseException(Throwable cause) {
1580
1559
return false ;
1581
1560
}
1582
1561
1583
- private final static int computeAndSetContentLength (Request request , HttpRequest r ) {
1562
+ private final static int getPredefinedContentLength (Request request , HttpRequest r ) {
1584
1563
int length = (int ) request .getContentLength ();
1585
1564
if (length == -1 && r .getHeader (HttpHeaders .Names .CONTENT_LENGTH ) != null ) {
1586
1565
length = Integer .valueOf (r .getHeader (HttpHeaders .Names .CONTENT_LENGTH ));
1587
1566
}
1588
1567
1589
- if (length >= 0 ) {
1590
- r .setHeader (HttpHeaders .Names .CONTENT_LENGTH , String .valueOf (length ));
1591
- }
1592
1568
return length ;
1593
1569
}
1594
1570
0 commit comments