We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9af2694 + c087476 commit 5b5b6aaCopy full SHA for 5b5b6aa
providers/netty/src/main/java/com/ning/http/client/providers/netty/ResponseBodyPart.java
@@ -67,9 +67,19 @@ public byte[] getBodyPartBytes() {
67
}
68
69
ChannelBuffer b = getChannelBuffer();
70
- byte[] rb = b.toByteBuffer().array();
71
- bytes.set(rb);
72
- return rb;
+ int readable = b.readableBytes();
+ int readerIndex = b.readerIndex();
+ if (b.hasArray()) {
73
+ byte[] array = b.array();
74
+ if (b.arrayOffset() == 0 && readerIndex == 0 && array.length == readable) {
75
+ bytes.set(array);
76
+ return array;
77
+ }
78
79
+ byte[] array = new byte[readable];
80
+ b.getBytes(readerIndex, array);
81
82
83
84
85
@Override
0 commit comments