List of usage examples for org.apache.http.nio ContentEncoderChannel ContentEncoderChannel
public ContentEncoderChannel(ContentEncoder contentEncoder)
From source file:org.jenkinsci.plugins.relution_publisher.net.requests.ZeroCopyFileRequestProducer.java
@Override public synchronized void produceContent(final ContentEncoder encoder, final IOControl ioctrl) throws IOException { if (!this.writeHeader(encoder, ioctrl)) { return;/*from w w w .j a v a 2s.co m*/ } if (this.mFileChannel == null) { this.mFileChannel = this.mAccessfile.getChannel(); this.mIndexFile = 0; } final long transferred; if (encoder instanceof FileContentEncoder) { transferred = ((FileContentEncoder) encoder).transfer(this.mFileChannel, this.mIndexFile, Integer.MAX_VALUE); } else { transferred = this.mFileChannel.transferTo(this.mIndexFile, Integer.MAX_VALUE, new ContentEncoderChannel(encoder)); } if (transferred > 0) { this.mIndexFile += transferred; } if (this.mIndexFile >= this.mFileChannel.size()) { if (this.writeFooter(encoder, ioctrl)) { this.closeChannel(); encoder.complete(); } } }