@Override public boolean writable() { return buffer.isWritable(); }
@Override public final boolean isWritable(int size) { return buf.isWritable(size); }
@Override public final boolean isWritable() { return buf.isWritable(); }
@Override public boolean isWritable(int size) { return buf.isWritable(size); }
@Override public boolean isWritable() { return buf.isWritable(); }
@Override public boolean isWritable(int size) { return buf.isWritable(size); }
@Override public final boolean isWritable() { return buf.isWritable(); }
@Override public final boolean isWritable(int size) { return buf.isWritable(size); }
@Override public boolean isWritable() { return buf.isWritable(); }
@Override public boolean isWritable() { return buf.isWritable(); }
@Override public boolean writable() { return buffer.isWritable(); }
@Override public final boolean isWritable(int size) { return buf.isWritable(size); }
@Override public final boolean isWritable() { return byteBuf.isWritable(); }
@Override public boolean isWritable(int size) { return buf.isWritable(size); }
@Override public final boolean isWritable() { return buf.isWritable(); }
/** * {@inheritDoc} * * Encodes the input buffer into {@link #blockSize} chunks in the output buffer. Data is only compressed and * written once we hit the {@link #blockSize}; else, it is copied into the backing {@link #buffer} to await * more data. */ @Override protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { if (finished) { if (!out.isWritable(in.readableBytes())) { // out should be EMPTY_BUFFER because we should have allocated enough space above in allocateBuffer. throw ENCODE_FINSHED_EXCEPTION; } out.writeBytes(in); return; } final ByteBuf buffer = this.buffer; int length; while ((length = in.readableBytes()) > 0) { final int nextChunkSize = Math.min(length, buffer.writableBytes()); in.readBytes(buffer, nextChunkSize); if (!buffer.isWritable()) { flushBufferedData(out); } } }
private BodyState readNextChunk(ByteBuf target) { BodyState res = BodyState.SUSPEND; while (target.isWritable() && state != BodyState.STOP) { BodyChunk nextChunk = queue.peek(); if (nextChunk == null) { // Nothing in the queue. suspend stream if nothing was read. (reads == 0) return res; } else if (!nextChunk.buffer.isReadable() && !nextChunk.last) { // skip empty buffers queue.remove(); } else { res = BodyState.CONTINUE; readChunk(target, nextChunk); } } return res; }
private static boolean attemptCopyToCumulation(ByteBuf cumulation, ByteBuf next, int wrapDataSize) { final int inReadableBytes = next.readableBytes(); final int cumulationCapacity = cumulation.capacity(); if (wrapDataSize - cumulation.readableBytes() >= inReadableBytes && // Avoid using the same buffer if next's data would make cumulation exceed the wrapDataSize. // Only copy if there is enough space available and the capacity is large enough, and attempt to // resize if the capacity is small. (cumulation.isWritable(inReadableBytes) && cumulationCapacity >= wrapDataSize || cumulationCapacity < wrapDataSize && ensureWritableSuccess(cumulation.ensureWritable(inReadableBytes, false)))) { cumulation.writeBytes(next); next.release(); return true; } return false; }
public BodyState transferTo(ByteBuf target) throws IOException { if (done) return BodyState.STOP; while (target.isWritable() && !done) { MultipartPart<? extends Part> currentPart = parts.get(currentPartIndex); currentPart.transferTo(target); if (currentPart.getState() == MultipartState.DONE) { currentPartIndex++; if (currentPartIndex == parts.size()) { done = true; } } } return BodyState.CONTINUE; }
if (!footer.isWritable()) {