Skip to content

Commit 91ea232

Browse files
author
Stephane Landelle
committed
InputStream shouldn't be fully read, this is streaming! close AsyncHttpClient#576
1 parent 815b7a2 commit 91ea232

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ protected final <T> void writeRequest(final Channel channel, final AsyncHttpClie
487487
Body body = null;
488488
if (!nettyRequest.getMethod().equals(HttpMethod.CONNECT)) {
489489
BodyGenerator bg = future.getRequest().getBodyGenerator();
490+
491+
if (bg == null && future.getRequest().getStreamData() != null) {
492+
bg = new InputStreamBodyGenerator(future.getRequest().getStreamData());
493+
}
494+
490495
if (bg != null) {
491496
// Netty issue with chunking.
492497
if (bg instanceof InputStreamBodyGenerator) {
@@ -834,12 +839,6 @@ else if (uri.getRawQuery() != null)
834839
byte[] bytes = request.getStringData().getBytes(bodyCharset);
835840
nettyRequest.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(bytes.length));
836841
nettyRequest.setContent(ChannelBuffers.wrappedBuffer(bytes));
837-
} else if (request.getStreamData() != null) {
838-
int[] lengthWrapper = new int[1];
839-
byte[] bytes = AsyncHttpProviderUtils.readFully(request.getStreamData(), lengthWrapper);
840-
int length = lengthWrapper[0];
841-
nettyRequest.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(length));
842-
nettyRequest.setContent(ChannelBuffers.wrappedBuffer(bytes, 0, length));
843842
} else if (isNonEmpty(request.getParams())) {
844843
StringBuilder sb = new StringBuilder();
845844
for (final Entry<String, List<String>> paramEntry : request.getParams()) {

0 commit comments

Comments
 (0)