public NettyHttpResponse(final ChannelHandlerContext ctx, final boolean keepAlive, final ResteasyProviderFactory providerFactory, final HttpMethod method) { outputHeaders = new MultivaluedMapImpl<String, Object>(); this.method = method; os = (method == null || !method.equals(HttpMethod.HEAD)) ? new ChunkOutputStream(this, ctx, 1000) : null; //[RESTEASY-1627] this.ctx = ctx; this.keepAlive = keepAlive; this.providerFactory = providerFactory; }
@Override public void close() throws IOException { flush(); super.close(); }
@Override public void write(int b) throws IOException { if (buffer.maxWritableBytes() < 1) { flush(); } buffer.writeByte(b); }
public NettyHttpResponse(ChannelHandlerContext ctx, boolean keepAlive, ResteasyProviderFactory providerFactory, HttpMethod method) { outputHeaders = new MultivaluedMapImpl<String, Object>(); this.method = method; os = (method == null || !method.equals(HttpMethod.HEAD)) ? new ChunkOutputStream(this, ctx, 1000) : null; //[RESTEASY-1627] this.ctx = ctx; this.keepAlive = keepAlive; this.providerFactory = providerFactory; }
@Override public void write(byte[] b, int off, int len) throws IOException { int dataLengthLeftToWrite = len; int dataToWriteOffset = off; int spaceLeftInCurrentChunk; while ((spaceLeftInCurrentChunk = buffer.maxWritableBytes()) < dataLengthLeftToWrite) { buffer.writeBytes(b, dataToWriteOffset, spaceLeftInCurrentChunk); dataToWriteOffset = dataToWriteOffset + spaceLeftInCurrentChunk; dataLengthLeftToWrite = dataLengthLeftToWrite - spaceLeftInCurrentChunk; flush(); } if (dataLengthLeftToWrite > 0) { buffer.writeBytes(b, dataToWriteOffset, dataLengthLeftToWrite); } }
@Override public void close() throws IOException { flush(); super.close(); }
@Override public void write(int b) throws IOException { if (buffer.maxWritableBytes() < 1) { flush(); } buffer.writeByte(b); }
@Override public void write(byte[] b, int off, int len) throws IOException { int dataLengthLeftToWrite = len; int dataToWriteOffset = off; int spaceLeftInCurrentChunk; while ((spaceLeftInCurrentChunk = buffer.maxWritableBytes()) < dataLengthLeftToWrite) { buffer.writeBytes(b, dataToWriteOffset, spaceLeftInCurrentChunk); dataToWriteOffset = dataToWriteOffset + spaceLeftInCurrentChunk; dataLengthLeftToWrite = dataLengthLeftToWrite - spaceLeftInCurrentChunk; flush(); } if (dataLengthLeftToWrite > 0) { buffer.writeBytes(b, dataToWriteOffset, dataLengthLeftToWrite); } }