org.apache.http.impl.io.ChunkedOutputStream
Implements chunked transfer coding.
See RFC 2616,
section 3.6.1.
Writes are buffered to an internal buffer (2048 default size).
Chunks are guaranteed to be at least as large as the buffer size
(except for the last chunk).
Summary
Public Constructors
Public Methods
Protected Methods
| |
|
|
|
void |
close() |
| |
|
|
|
void |
flush() |
| |
|
|
|
void |
write(byte[] buffer) |
| abstract |
|
|
|
void |
write(int oneByte) |
| |
|
|
|
void |
write(byte[] buffer, int offset, int count) |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Public Constructors
public
ChunkedOutputStream(SessionOutputBuffer out, int bufferSize)
Wraps a session output buffer and chunks the output.
Parameters
| out
| the session output buffer to wrap |
| bufferSize
| minimum chunk size (excluding last chunk) |
Wraps a session output buffer and chunks the output. The default buffer
size of 2048 was chosen because the chunk overhead is less than 0.5%
Parameters
| out
| the output buffer to wrap |
Public Methods
public
void
close()
Finishes writing to the underlying stream, but does NOT close the underlying stream.
public
void
finish()
Must be called to ensure the internal cache is flushed and the closing chunk is written.
public
void
flush()
Flushes the underlying stream, but leaves the internal buffer alone.
public
void
write(byte[] b)
Writes the array. If the array does not fit within the buffer, it is
not split, but rather written out as one large chunk.
Parameters
| b
| the buffer to be written |
public
void
write(int b)
Writes the specified byte
oneByte to this OutputStream.
Only the low order byte of
oneByte is written.
public
void
write(byte[] src, int off, int len)
Writes
count bytes from the byte array
buffer starting at
offset to this
OutputStream.
Parameters
| src
| the buffer to be written |
| off
| offset in buffer to get bytes |
| len
| number of bytes in buffer to write |
Protected Methods
protected
void
flushCache()
Writes the cache out onto the underlying stream
protected
void
flushCacheWithAppend(byte[] bufferToAppend, int off, int len)
Writes the cache and bufferToAppend to the underlying stream
as one large chunk
protected
void
writeClosingChunk()