@Override public void flush() { checkClose(); buf.flip(); if (buf.limit() == 0) { bufs.release(buf); return; } out.offer(buf, new ReleaseCallback(bufs, buf)); buf = acquire(); }
/** * Adds the given content buffer to this content provider * and notifies the listener that content is available. * * @param buffer the content to add * @return true if the content was added, false otherwise */ public boolean offer(ByteBuffer buffer) { return offer(buffer, Callback.NOOP); }
/** * Creates a new {@link DeferredContentProvider} with the given initial content * * @param buffers the initial content */ public DeferredContentProvider(ByteBuffer... buffers) { for (ByteBuffer buffer : buffers) offer(buffer); }
protected void write(ByteBuffer buffer) { deferred.offer(buffer); }
protected void write(ByteBuffer buffer) { deferred.offer(buffer); }
protected void write(ByteBuffer buffer) { deferred.offer(buffer); }
@Override public void onNext(ContentChunk chunk) { provider.offer(chunk.buffer, new Callback.Nested(chunk.callback) { @Override public void succeeded() { super.succeeded(); subscription.request(1); } @Override public void failed(Throwable x) { super.failed(x); subscription.cancel(); } }); }
@Override public void onDataReceived(ByteBuffer buffer) { targetReqBody.offer(buffer); }
@Override public void onNext(ContentChunk chunk) { provider.offer(chunk.buffer, new Callback.Nested(chunk.callback) { @Override public void succeeded() { super.succeeded(); subscription.request(1); } @Override public void failed(Throwable x) { super.failed(x); subscription.cancel(); } }); }
/** * No more content will be added to this content provider * and notifies the listener that no more content is available. */ @Override public void close() { if (closed.compareAndSet(false, true)) offer(CLOSE); }
protected void onRequestContent(HttpServletRequest request, Request proxyRequest, DeferredContentProvider provider, byte[] buffer, int offset, int length, Callback callback) { provider.offer(ByteBuffer.wrap(buffer, offset, length), callback); }
@Override protected Action process() throws Exception { if (!iterator.hasNext()) return Action.SUCCEEDED; ByteBuffer buffer = iterator.next(); if (buffer == null) return Action.IDLE; deferred.offer(buffer, this); return Action.SCHEDULED; }
public boolean offer(ByteBuffer buffer, Callback callback) { return offer(new Chunk(buffer, callback)); }
@Override public boolean offer(ByteBuffer buffer, Callback callback) { if (_log.isDebugEnabled()) _log.debug("{} proxying content to upstream: {} bytes", getRequestId(clientRequest), buffer.remaining()); return super.offer(buffer, callback); } }
provider.offer(buffer, counter);
@Override public void onData(Stream clientStream, final DataInfo clientDataInfo) { if (LOG.isDebugEnabled()) LOG.debug("received clientDataInfo: {} for stream: {}", clientDataInfo, clientStream); DeferredContentProvider contentProvider = (DeferredContentProvider)request.getContent(); contentProvider.offer(clientDataInfo.asByteBuffer(true)); if (clientDataInfo.isClose()) contentProvider.close(); } };