--- old/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseProcessors.java 2017-08-03 17:42:13.000000000 +0100 +++ new/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseProcessors.java 2017-08-03 17:42:13.000000000 +0100 @@ -72,10 +72,12 @@ } @Override - public void onNext(ByteBuffer item) { - byte[] buf = new byte[item.remaining()]; - item.get(buf); - consumer.accept(Optional.of(buf)); + public void onNext(List items) { + for (ByteBuffer item : items) { + byte[] buf = new byte[item.remaining()]; + item.get(buf); + consumer.accept(Optional.of(buf)); + } subscription.request(1); } @@ -120,9 +122,11 @@ } @Override - public void onNext(ByteBuffer item) { + public void onNext(List items) { try { - out.write(item); + for (ByteBuffer item : items) { + out.write(item); + } } catch (IOException ex) { Utils.close(out); subscription.cancel(); @@ -172,12 +176,12 @@ } @Override - public void onNext(ByteBuffer item) { + public void onNext(List items) { // incoming buffers are allocated by http client internally, // and won't be used anywhere except this place. // So it's free simply to store them for further processing. - if(item.hasRemaining()) { - received.add(item); + if(Utils.remaining(items) > 0) { + received.addAll(items); } } @@ -304,9 +308,11 @@ } @Override - public void onNext(ByteBuffer item) { + public void onNext(List items) { // TODO: check whether this should consume the buffer, as in: - item.position(item.limit()); + for (ByteBuffer item : items) { + item.position(item.limit()); + } } @Override