public ContentOutputBuffer getOutbuffer() { if (this.outbuffer == null) { this.outbuffer = new SimpleOutputBuffer(2048, allocator); } return this.outbuffer; }
@Override public void write(final int b) throws IOException { if (this.endOfStream) { return; } setInputMode(); ensureCapacity(this.capacity() + 1); this.buffer.put((byte)b); }
public void write(final byte[] b) throws IOException { if (b == null) { return; } if (this.endOfStream) { return; } write(b, 0, b.length); }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (b == null) { return; } if (this.endOfStream) { return; } setInputMode(); ensureCapacity(this.buffer.position() + len); this.buffer.put(b, off, len); }
@Override public int produceContent(final ContentEncoder encoder) throws IOException { setOutputMode(); final int bytesWritten = encoder.write(this.buffer); if (!hasData() && this.endOfStream) { encoder.complete(); } return bytesWritten; }
if(outBuf instanceof SimpleOutputBuffer && !((SimpleOutputBuffer)outBuf).hasData()){ sourceConfiguration.getSourceConnections().releaseConnection(conn);
@Override public int produceContent(final ContentEncoder encoder) throws IOException { setOutputMode(); final int bytesWritten = encoder.write(this.buffer); if (!hasData() && this.endOfStream) { encoder.complete(); } return bytesWritten; }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (b == null) { return; } if (this.endOfStream) { return; } setInputMode(); ensureCapacity(this.buffer.position() + len); this.buffer.put(b, off, len); }
@Override public void write(final int b) throws IOException { if (this.endOfStream) { return; } setInputMode(); ensureCapacity(this.capacity() + 1); this.buffer.put((byte)b); }
public void write(final byte[] b) throws IOException { if (b == null) { return; } if (this.endOfStream) { return; } write(b, 0, b.length); }
/** * Create synapse.response-source-buffer for GET and HEAD Http methods * @param method Http Method * @param request Source Request * @return OutputStream */ public OutputStream getOutputStream(String method,SourceRequest request){ OutputStream os=null; if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method)) { HttpContext context = request.getConnection().getContext(); ContentOutputBuffer outputBuffer = new SimpleOutputBuffer( sourceConfiguration.getIOBufferSize(), new HeapByteBufferAllocator()); context.setAttribute("synapse.response-source-buffer",outputBuffer); os = new ContentOutputStream(outputBuffer); } return os; }