@@ -400,31 +400,7 @@ protected final <T> void writeRequest(final Channel channel,
400
400
401
401
if (future .getAndSetWriteBody (true )) {
402
402
if (!future .getNettyRequest ().getMethod ().equals (HttpMethod .CONNECT )) {
403
- if (future .getRequest ().getParts () != null ) {
404
- String boundary = future .getNettyRequest ().getHeader ("Content-Type" );
405
- String length = future .getNettyRequest ().getHeader ("Content-Length" );
406
- final MultipartBody multipartBody = new MultipartBody (future .getRequest ().getParts (), boundary , length );
407
-
408
- ChannelFuture writeFuture ;
409
- if (channel .getPipeline ().get (SslHandler .class ) == null ) {
410
- writeFuture = channel .write (new BodyFileRegion (multipartBody ));
411
- } else {
412
- writeFuture = channel .write (new BodyChunkedInput (multipartBody ));
413
- }
414
-
415
- writeFuture .addListener (new ProgressListener (false , future .getAsyncHandler (), future ) {
416
-
417
- public void operationComplete (ChannelFuture cf ) {
418
- try {
419
- multipartBody .close ();
420
- } catch (IOException e ) {
421
- log .warn ("Failed to close request body: {}" , e .getMessage (), e );
422
- }
423
- super .operationComplete (cf );
424
- }
425
-
426
- });
427
- } else if (future .getRequest ().getFile () != null ) {
403
+ if (future .getRequest ().getFile () != null ) {
428
404
final File file = future .getRequest ().getFile ();
429
405
long fileLength = 0 ;
430
406
final RandomAccessFile raf = new RandomAccessFile (file , "r" );
@@ -706,6 +682,11 @@ private static HttpRequest construct(AsyncHttpClientConfig config,
706
682
707
683
nettyRequest .setHeader (HttpHeaders .Names .CONTENT_TYPE , mre .getContentType ());
708
684
nettyRequest .setHeader (HttpHeaders .Names .CONTENT_LENGTH , String .valueOf (mre .getContentLength ()));
685
+
686
+ ChannelBuffer b = ChannelBuffers .dynamicBuffer (lenght );
687
+ mre .writeRequest (new ChannelBufferOutputStream (b ));
688
+ nettyRequest .setContent (b );
689
+
709
690
} else if (request .getEntityWriter () != null ) {
710
691
int lenght = computeAndSetContentLength (request , nettyRequest );
711
692
0 commit comments