@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; }
private void computeLength(List<HttpResponseBodyPart> parts) { if (available == 0) { for (HttpResponseBodyPart p : parts) { available += p.getBodyPartBytes().length; } } }
@Override public int read() throws IOException { if (++bytePos >= active.length) { // No more bytes, so step to the next array. if (++currentPos >= parts.size()) { return -1; } bytePos = 0; active = parts.get(currentPos).getBodyPartBytes(); } return active[bytePos] & 0xFF; } }
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 void onPing(HttpResponseBodyPart part) { for (WebSocketListener listener : listeners) { if (listener instanceof WebSocketPingListener) // bytes are cached in the part WebSocketPingListener.class.cast(listener).onPing(part.getBodyPartBytes()); } }
public void onPong(HttpResponseBodyPart part) { for (WebSocketListener listener : listeners) { if (listener instanceof WebSocketPongListener) // bytes are cached in the part WebSocketPongListener.class.cast(listener).onPong(part.getBodyPartBytes()); } } }
public HttpResponseBodyPartsInputStream(List<HttpResponseBodyPart> parts) { this.parts = parts; active = parts.get(0).getBodyPartBytes(); computeLength(parts); }
@Override public STATE onBodyPartReceived(final HttpResponseBodyPart content) throws Exception { STATE s = STATE.CONTINUE; if (accumulateResponseBytes) { s = super.onBodyPartReceived(content); } fireOnBytesReceived(content.getBodyPartBytes()); return s; }
@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 computeLength(List<HttpResponseBodyPart> parts) { if (available == 0) { for (HttpResponseBodyPart p : parts) { available += p.getBodyPartBytes().length; } } }
private void computeLength(List<HttpResponseBodyPart> parts) { if (available == 0) { for (HttpResponseBodyPart p : parts) { available += p.getBodyPartBytes().length; } } }
/** * {@inheritDoc} */ @Override public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { logger.trace("Body received {}", new String(bodyPart.getBodyPartBytes())); return STATE.CONTINUE; }
/** * {@inheritDoc} */ @Override public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { logger.trace("Body received {}", new String(bodyPart.getBodyPartBytes())); return STATE.CONTINUE; }
public HttpResponseBodyPartsInputStream(List<HttpResponseBodyPart> parts) { this.parts = parts; active = parts.get(0).getBodyPartBytes(); computeLength(parts); }
public HttpResponseBodyPartsInputStream(List<HttpResponseBodyPart> parts) { this.parts = parts; active = parts.get(0).getBodyPartBytes(); computeLength(parts); }
@Override public STATE onBodyPartReceived(final HttpResponseBodyPart content) throws Exception { STATE s = STATE.CONTINUE; if (accumulateResponseBytes) { s = super.onBodyPartReceived(content); } fireOnBytesReceived(content.getBodyPartBytes()); return s; }
@Override public STATE onBodyPartReceived(HttpResponseBodyPart content) throws Exception { builder.append(new String(content.getBodyPartBytes())); return STATE.CONTINUE; }
@Override public STATE onBodyPartReceived(final HttpResponseBodyPart content) throws Exception { STATE s = STATE.CONTINUE; if (accumulateResponseBytes) { s = super.onBodyPartReceived(content); } fireOnBytesReceived(content.getBodyPartBytes()); return s; }
@Override public STATE onBodyPartReceived(HttpResponseBodyPart content) throws Exception { builder.append(new String(content.getBodyPartBytes())); return STATE.CONTINUE; }
public STATE onBodyPartReceived(HttpResponseBodyPart e) throws Exception { String s = new String(e.getBodyPartBytes()); log.info("got part: {}", s); if (s.isEmpty()) { // noinspection ThrowableInstanceNeverThrown log.warn("Sampling stacktrace.", new Throwable("trace that, we should not get called for empty body.")); } queue.put(s); return STATE.CONTINUE; }