@Override public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { bodyPart.writeTo(wrappedOutputStream); wrappedOutputStream.flush(); return STATE.CONTINUE; }
@Override public AsyncHandler.STATE onBodyPartReceived(final HttpResponseBodyPart bodyPart) throws Exception { sb.append(new String(bodyPart.getBodyPartBytes(), StandardCharsets.UTF_8)); latch.countDown(); return AsyncHandler.STATE.CONTINUE; }
@Override public AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { if (accumulateBody) { responseBuilder.accumulate(bodyPart); } STATE state = STATE.CONTINUE; try { resumableListener.onBytesReceived(bodyPart.getBodyByteBuffer()); } catch (IOException ex) { return AsyncHandler.STATE.ABORT; } if (decoratedAsyncHandler != null) { state = decoratedAsyncHandler.onBodyPartReceived(bodyPart); } byteTransferred.addAndGet(bodyPart.getBodyPartBytes().length); resumableProcessor.put(url, byteTransferred.get()); return state; }
public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { bodyPart.writeTo(stream); if (bodyPart.getBodyPartBytes().length == 0) { return STATE.ABORT; } return STATE.CONTINUE; }
if (bodyPart.isLast()) { LOGGER.debug("Single part (size = {}bytes).", bodyPart.getBodyByteBuffer().remaining()); int bodyLength = bodyPart.getBodyByteBuffer().remaining(); LOGGER.debug("Multiple parts (part size = {} bytes, PipedInputStream buffer size = {} bytes).", bodyLength, bufferSize); if (bufferSize - input.get().available() < bodyLength) { bodyPart.writeTo(output); } catch (IOException e) { this.onThrowable(e);
@Override public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { entityStream.put(bodyPart.getBodyByteBuffer()); return STATE.CONTINUE; }
/** * @param bodyPart * a body part (possibly empty, but will be filtered out) * @return this */ public ResponseBuilder accumulate(HttpResponseBodyPart bodyPart) { if (bodyPart.length() > 0) bodyParts.add(bodyPart); return this; }
public void onTextFragment(HttpResponseBodyPart part) { for (WebSocketListener listener : listeners) { if (listener instanceof WebSocketTextFragmentListener) WebSocketTextFragmentListener.class.cast(listener).onFragment(part); } if (interestedInTextMessages) { ChannelBuffer fragment = NettyResponseBodyPart.class.cast(part).getChannelBuffer(); if (part.isLast()) { if (bufferSize == 0) { notifyTextListeners(fragment); } else { bufferFragment(fragment); notifyTextListeners(wrappedBuffer(fragments().toArray(new ChannelBuffer[fragments().size()]))); } reset(); } else bufferFragment(fragment); } }
public STATE onBodyPartReceived(HttpResponseBodyPart content) throws Exception { builder.accumulate(content); if (content.isLast()) { content.markUnderlyingConnectionAsToBeClosed(); } return STATE.CONTINUE; }
@Override public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { entityStream.put(bodyPart.getBodyByteBuffer()); return STATE.CONTINUE; }
/** * @param bodyPart * a body part (possibly empty, but will be filtered out) * @return this */ public ResponseBuilder accumulate(HttpResponseBodyPart bodyPart) { if (bodyPart.length() > 0) bodyParts.add(bodyPart); return this; }
public void onBinaryFragment(HttpResponseBodyPart part) { for (WebSocketListener listener : listeners) { if (listener instanceof WebSocketByteFragmentListener) WebSocketByteFragmentListener.class.cast(listener).onFragment(part); } if (interestedInByteMessages) { ChannelBuffer fragment = NettyResponseBodyPart.class.cast(part).getChannelBuffer(); if (part.isLast()) { if (bufferSize == 0) { notifyByteListeners(fragment); } else { bufferFragment(fragment); notifyByteListeners(wrappedBuffer(fragments().toArray(new ChannelBuffer[fragments().size()]))); } reset(); } else bufferFragment(fragment); } }
private void computeLength(List<HttpResponseBodyPart> parts) { if (available == 0) { for (HttpResponseBodyPart p : parts) { available += p.getBodyPartBytes().length; } } }
public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { // body arrived, flush headers if (!responseSet) { response = responseBuilder.build(); responseSet = true; headersArrived.countDown(); } bodyPart.writeTo(output); return STATE.CONTINUE; }
@Override public AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { if (accumulateBody) { responseBuilder.accumulate(bodyPart); } STATE state = STATE.CONTINUE; try { resumableListener.onBytesReceived(bodyPart.getBodyByteBuffer()); } catch (IOException ex) { return AsyncHandler.STATE.ABORT; } if (decoratedAsyncHandler != null) { state = decoratedAsyncHandler.onBodyPartReceived(bodyPart); } byteTransferred.addAndGet(bodyPart.getBodyPartBytes().length); resumableProcessor.put(url, byteTransferred.get()); return state; }
private void fireReceived(HttpResponseBodyPart content) { int remaining = content.getBodyByteBuffer().remaining(); amount += remaining; if (listener != null) { listener.onBytesReceived(uri, amount, remaining, total); } }
/** * @param bodyPart * a body part (possibly empty, but will be filtered out) * @return this */ public ResponseBuilder accumulate(HttpResponseBodyPart bodyPart) { if (bodyPart.length() > 0) bodyParts.add(bodyPart); return this; }
public void onTextFragment(HttpResponseBodyPart part) { for (WebSocketListener listener : listeners) { if (listener instanceof WebSocketTextFragmentListener) WebSocketTextFragmentListener.class.cast(listener).onFragment(part); } if (interestedInTextMessages) { ChannelBuffer fragment = NettyResponseBodyPart.class.cast(part).getChannelBuffer(); if (part.isLast()) { if (bufferSize == 0) { notifyTextListeners(fragment); } else { bufferFragment(fragment); notifyTextListeners(wrappedBuffer(fragments().toArray(new ChannelBuffer[fragments().size()]))); } reset(); } else bufferFragment(fragment); } }
public final static byte[] contentToByte(List<HttpResponseBodyPart> bodyParts) throws UnsupportedEncodingException { if (bodyParts.size() == 1) { return bodyParts.get(0).getBodyPartBytes(); } else { int size = 0; for (HttpResponseBodyPart body : bodyParts) { size += body.getBodyPartBytes().length; } byte[] bytes = new byte[size]; int offset = 0; for (HttpResponseBodyPart body : bodyParts) { byte[] bodyBytes = body.getBodyPartBytes(); System.arraycopy(bodyBytes, 0, bytes, offset, bodyBytes.length); offset += bodyBytes.length; } return bytes; } }
public STATE onBodyPartReceived(HttpResponseBodyPart content) throws Exception { if (status == 200) { content.writeTo(this.out); } return STATE.CONTINUE; }