@Override protected OutputStream createOutputStream(final long len, final SessionOutputBuffer outbuffer) { if (len == ContentLengthStrategy.CHUNKED) { return new ChunkedOutputStream(chunkSize, outbuffer); } return super.createOutputStream(len, outbuffer); } }
/** * Finishes writing to the underlying stream, but does NOT close the underlying stream. * @throws IOException */ public void close() throws IOException { if (!this.closed) { this.closed = true; finish(); this.out.flush(); } } }
/** * Must be called to ensure the internal cache is flushed and the closing chunk is written. * @throws IOException */ public void finish() throws IOException { if (!this.wroteLastChunk) { flushCache(); writeClosingChunk(); this.wroteLastChunk = true; } }
public void write(int b) throws IOException { if (this.closed) { throw new IOException("Attempted write to closed stream."); } this.cache[this.cachePosition] = (byte) b; this.cachePosition++; if (this.cachePosition == this.cache.length) flushCache(); }
public void write(byte src[], int off, int len) throws IOException { if (this.closed) { throw new IOException("Attempted write to closed stream."); } if (len >= this.cache.length - this.cachePosition) { flushCacheWithAppend(src, off, len); } else { System.arraycopy(src, off, cache, this.cachePosition, len); this.cachePosition += len; } }
/** * Writes the array. If the array does not fit within the buffer, it is * not split, but rather written out as one large chunk. * @param b * @throws IOException */ public void write(byte b[]) throws IOException { write(b, 0, b.length); }
/** * Flushes the content buffer and the underlying stream. * @throws IOException */ public void flush() throws IOException { flushCache(); this.out.flush(); }
public void write(byte src[], int off, int len) throws IOException { if (this.closed) { throw new IOException("Attempted write to closed stream."); } if (len >= this.cache.length - this.cachePosition) { flushCacheWithAppend(src, off, len); } else { System.arraycopy(src, off, cache, this.cachePosition, len); this.cachePosition += len; } }
/** * Writes the array. If the array does not fit within the buffer, it is * not split, but rather written out as one large chunk. * @param b * @throws IOException */ public void write(byte b[]) throws IOException { write(b, 0, b.length); }
/** * Must be called to ensure the internal cache is flushed and the closing chunk is written. * @throws IOException */ public void finish() throws IOException { if (!this.wroteLastChunk) { flushCache(); writeClosingChunk(); this.wroteLastChunk = true; } }
protected OutputStream doSerialize( final SessionOutputBuffer outbuffer, final HttpMessage message) throws HttpException, IOException { long len = this.lenStrategy.determineLength(message); if (len == ContentLengthStrategy.CHUNKED) { return new ChunkedOutputStream(outbuffer); } else if (len == ContentLengthStrategy.IDENTITY) { return new IdentityOutputStream(outbuffer); } else { return new ContentLengthOutputStream(outbuffer, len); } }
public void write(int b) throws IOException { if (this.closed) { throw new IOException("Attempted write to closed stream."); } this.cache[this.cachePosition] = (byte) b; this.cachePosition++; if (this.cachePosition == this.cache.length) flushCache(); }
public void write(byte src[], int off, int len) throws IOException { if (this.closed) { throw new IOException("Attempted write to closed stream."); } if (len >= this.cache.length - this.cachePosition) { flushCacheWithAppend(src, off, len); } else { System.arraycopy(src, off, cache, this.cachePosition, len); this.cachePosition += len; } }
/** * Writes the array. If the array does not fit within the buffer, it is * not split, but rather written out as one large chunk. */ @Override public void write(final byte b[]) throws IOException { write(b, 0, b.length); }
/** * Finishes writing to the underlying stream, but does NOT close the underlying stream. * @throws IOException */ public void close() throws IOException { if (!this.closed) { this.closed = true; finish(); this.out.flush(); } } }
/** * Must be called to ensure the internal cache is flushed and the closing * chunk is written. * @throws IOException in case of an I/O error */ public void finish() throws IOException { if (!this.wroteLastChunk) { flushCache(); writeClosingChunk(); this.wroteLastChunk = true; } }
@Override protected OutputStream createOutputStream(final long len, final SessionOutputBuffer outbuffer) { if (len == ContentLengthStrategy.CHUNKED) { return new ChunkedOutputStream(chunkSize, outbuffer); } return super.createOutputStream(len, outbuffer); } }
@Override public void write(final int b) throws IOException { if (this.closed) { throw new IOException("Attempted write to closed stream."); } this.cache[this.cachePosition] = (byte) b; this.cachePosition++; if (this.cachePosition == this.cache.length) { flushCache(); } }
public void write(byte src[], int off, int len) throws IOException { if (this.closed) { throw new IOException("Attempted write to closed stream."); } if (len >= this.cache.length - this.cachePosition) { flushCacheWithAppend(src, off, len); } else { System.arraycopy(src, off, cache, this.cachePosition, len); this.cachePosition += len; } }
/** * Writes the array. If the array does not fit within the buffer, it is * not split, but rather written out as one large chunk. */ @Override public void write(final byte b[]) throws IOException { write(b, 0, b.length); }