@Override public void endStream() throws IOException { if (log.isDebugEnabled()) { log.debug(exchangeId + ": end of request data"); } channel.endStream(); }
@Override public void endStream(final List<? extends Header> trailers) throws IOException { if (log.isDebugEnabled()) { log.debug(exchangeId + ": end of request data"); } channel.endStream(trailers); }
@Override public final void produce(final DataStreamChannel channel) throws IOException { if (bytebuf.hasRemaining()) { channel.write(bytebuf); } if (!bytebuf.hasRemaining()) { channel.endStream(); } }
@Override public void produce(final DataStreamChannel channel) throws IOException { if (outputTerminated.get()) { channel.endStream(); return; } requestProducer.produce(channel); }
@Override public final void produce(final DataStreamChannel channel) throws IOException { if (bytebuf.hasRemaining()) { channel.write(bytebuf); } if (!bytebuf.hasRemaining()) { channel.endStream(); } }
@Override public void produce(final DataStreamChannel channel) throws IOException { if (outputTerminated.get()) { channel.endStream(); return; } requestProducer.produce(channel); }
@Override public void endStream(final List<? extends Header> trailers) throws IOException { digest = digester.digest(); final List<Header> allTrailers = new ArrayList<>(); if (trailers != null) { allTrailers.addAll(trailers); } allTrailers.add(new BasicHeader("digest-algo", digester.getAlgorithm())); allTrailers.add(new BasicHeader("digest", TextUtils.toHexString(digest))); channel.endStream(allTrailers); }
@Override public void produce(final DataStreamChannel channel) throws IOException { @SuppressWarnings("resource") RandomAccessFile accessFile = accessFileRef.get(); if (accessFile == null) { accessFile = new RandomAccessFile(file, "r"); Asserts.check(accessFileRef.getAndSet(accessFile) == null, "Illegal producer state"); } if (!eof) { final int bytesRead = accessFile.getChannel().read(byteBuffer); if (bytesRead < 0) { eof = true; } } if (byteBuffer.position() > 0) { byteBuffer.flip(); channel.write(byteBuffer); byteBuffer.compact(); } if (eof && byteBuffer.position() == 0) { channel.endStream(); releaseResources(); } }
@Override public void endStream(final List<? extends Header> trailers) throws IOException { digest = digester.digest(); final List<Header> allTrailers = new ArrayList<>(); if (trailers != null) { allTrailers.addAll(trailers); } allTrailers.add(new BasicHeader("digest-algo", digester.getAlgorithm())); allTrailers.add(new BasicHeader("digest", TextUtils.toHexString(digest))); channel.endStream(allTrailers); }
@Override public void produce(final DataStreamChannel channel) throws IOException { @SuppressWarnings("resource") RandomAccessFile accessFile = accessFileRef.get(); if (accessFile == null) { accessFile = new RandomAccessFile(file, "r"); Asserts.check(accessFileRef.getAndSet(accessFile) == null, "Illegal producer state"); } if (!eof) { final int bytesRead = accessFile.getChannel().read(byteBuffer); if (bytesRead < 0) { eof = true; } } if (byteBuffer.position() > 0) { byteBuffer.flip(); channel.write(byteBuffer); byteBuffer.compact(); } if (eof && byteBuffer.position() == 0) { channel.endStream(); releaseResources(); } }
@Override public void writeCompleted() throws IOException { if (endStream) { return; } lock.lock(); try { if (!endStream) { endStream = true; if (dataStreamChannel != null) { setOutputMode(); if (buffer().hasRemaining()) { dataStreamChannel.requestOutput(); } else { dataStreamChannel.endStream(); } } } } finally { lock.unlock(); } }
@Override public void writeCompleted() throws IOException { if (endStream) { return; } lock.lock(); try { if (!endStream) { endStream = true; if (dataStreamChannel != null) { setOutputMode(); if (buffer().hasRemaining()) { dataStreamChannel.requestOutput(); } else { dataStreamChannel.endStream(); } } } } finally { lock.unlock(); } }
@Override public final void produce(final DataStreamChannel channel) throws IOException { synchronized (bytebuf) { if (state == State.ACTIVE) { produceData(new StreamChannel<ByteBuffer>() { @Override public int write(final ByteBuffer src) throws IOException { Args.notNull(src, "Buffer"); synchronized (bytebuf) { return writeData(channel, src); } } @Override public void endStream() throws IOException { synchronized (bytebuf) { streamEnd(channel); } } }); } if (state == State.FLUSHING) { flush(channel); if (bytebuf.position() == 0) { state = State.END_STREAM; channel.endStream(); } } } }
throw new HttpStreamResetException(t.getMessage(), t); } else if (this.complete.get() && buffers.isEmpty()) { channel.endStream(); } else { while (buffers.size() > 0) {
throw new HttpStreamResetException(t.getMessage(), t); } else if (this.complete.get() && buffers.isEmpty()) { channel.endStream(); } else { while (buffers.size() > 0) {
public void flush(final DataStreamChannel channel) throws IOException { lock.lock(); try { dataStreamChannel = channel; hasCapacity = true; setOutputMode(); if (buffer().hasRemaining()) { dataStreamChannel.write(buffer()); } if (!buffer().hasRemaining() && endStream) { dataStreamChannel.endStream(); } condition.signalAll(); } finally { lock.unlock(); } }
public void flush(final DataStreamChannel channel) throws IOException { lock.lock(); try { dataStreamChannel = channel; hasCapacity = true; setOutputMode(); if (buffer().hasRemaining()) { dataStreamChannel.write(buffer()); } if (!buffer().hasRemaining() && endStream) { dataStreamChannel.endStream(); } condition.signalAll(); } finally { lock.unlock(); } }
@Override public final void produce(final DataStreamChannel channel) throws IOException { if (state.compareTo(State.ACTIVE) == 0) { produceData(charDataStream); } if (state.compareTo(State.ACTIVE) > 0 || !bytebuf.hasRemaining() || bytebuf.position() >= fragmentSizeHint) { bytebuf.flip(); channel.write(bytebuf); bytebuf.compact(); } if (state.compareTo(State.FLUSHING) == 0) { final CoderResult result = charsetEncoder.encode(EMPTY, bytebuf, true); if (result.isError()) { result.throwException(); } else if (result.isUnderflow()) { final CoderResult result2 = charsetEncoder.flush(bytebuf); if (result2.isError()) { result.throwException(); } else if (result2.isUnderflow()) { state = State.END_STREAM; } } } if (bytebuf.position() == 0 && state.compareTo(State.END_STREAM) == 0) { channel.endStream(); } }
if (bytebuf.position() == 0) { state = State.END_STREAM; channel.endStream();