Skip to content

Commit 56815d5

Browse files
committed
Changes for AsyncHttpClient#230.
1 parent 232aab0 commit 56815d5

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

api/src/main/java/com/ning/http/client/consumers/AppendableBodyConsumer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010-2012 Sonatype, Inc. All rights reserved.
2+
* Copyright (c) 2010-2013 Sonatype, Inc. All rights reserved.
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
@@ -41,7 +41,10 @@ public AppendableBodyConsumer(Appendable appendable) {
4141
*/
4242
/* @Override */
4343
public void consume(ByteBuffer byteBuffer) throws IOException {
44-
appendable.append(new String(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.remaining(), encoding));
44+
appendable.append(new String(byteBuffer.array(),
45+
byteBuffer.arrayOffset() + byteBuffer.position(),
46+
byteBuffer.remaining(),
47+
encoding));
4548
}
4649

4750
/**

api/src/main/java/com/ning/http/client/consumers/FileBodyConsumer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010-2012 Sonatype, Inc. All rights reserved.
2+
* Copyright (c) 2010-2013 Sonatype, Inc. All rights reserved.
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
@@ -35,7 +35,9 @@ public FileBodyConsumer(RandomAccessFile file) {
3535
/* @Override */
3636
public void consume(ByteBuffer byteBuffer) throws IOException {
3737
// TODO: Channel.transferFrom may be a good idea to investigate.
38-
file.write(byteBuffer.array());
38+
file.write(byteBuffer.array(),
39+
byteBuffer.arrayOffset() + byteBuffer.position(),
40+
byteBuffer.remaining());
3941
}
4042

4143
/**

api/src/main/java/com/ning/http/client/consumers/OutputStreamBodyConsumer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010-2012 Sonatype, Inc. All rights reserved.
2+
* Copyright (c) 2010-2013 Sonatype, Inc. All rights reserved.
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
@@ -34,7 +34,9 @@ public OutputStreamBodyConsumer(OutputStream outputStream) {
3434
*/
3535
/* @Override */
3636
public void consume(ByteBuffer byteBuffer) throws IOException {
37-
outputStream.write(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.remaining());
37+
outputStream.write(byteBuffer.array(),
38+
byteBuffer.arrayOffset() + byteBuffer.position(),
39+
byteBuffer.remaining());
3840
}
3941

4042
/**

0 commit comments

Comments
 (0)