java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
net.i2p.i2ptunnel.util.LimitOutputStream
net.i2p.i2ptunnel.util.DechunkedOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Simple stream for checking and optionally removing RFC2616 chunked encoding to the output.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumThe states of the chunk parser.Nested classes/interfaces inherited from class LimitOutputStream
LimitOutputStream.DoneCallbackModifier and TypeClassDescriptionstatic interfaceCallback interface for notification when a limited output stream completes.Field Summary
FieldsModifier and TypeFieldDescriptionprivate intBytes left in the current chunk, or the trailer header size.private DechunkedOutputStream.StateThe current state of the chunk parser.private final booleanTrue to strip the chunk headers and footers.Fields inherited from class LimitOutputStream
_callback, _isDoneModifier and TypeFieldDescriptionprotected final LimitOutputStream.DoneCallbackInvoked once byLimitOutputStream.setDone()when the subclass has finished writing.protected booleanTrue once setDone() has run, so the callback cannot fire twice.Fields inherited from class FilterOutputStream
outConstructor Summary
ConstructorsConstructorDescriptionDechunkedOutputStream(OutputStream raw, LimitOutputStream.DoneCallback callback, boolean strip) Creates a new dechunked output stream.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidwrite(byte[] buf, int off, int len) Subclasses MUST override the following method such that it calls done() when finished and throws EOFException if called again.Methods inherited from class LimitOutputStream
isDone, setDone, writeMethods inherited from class FilterOutputStream
close, flush, writeMethods inherited from class OutputStream
nullOutputStream
Field Details
_strip
private final boolean _stripTrue to strip the chunk headers and footers._state
The current state of the chunk parser._remaining
private int _remainingBytes left in the current chunk, or the trailer header size.
Constructor Details
DechunkedOutputStream
public DechunkedOutputStream(OutputStream raw, LimitOutputStream.DoneCallback callback, boolean strip) Creates a new dechunked output stream.- Parameters:
raw- the underlying output streamcallback- callback invoked when chunking is completestrip- true to strip chunk headers/footers, false to pass them through
Method Details
write
Description copied from class:LimitOutputStreamSubclasses MUST override the following method such that it calls done() when finished and throws EOFException if called again.- Overrides:
writein classLimitOutputStream- Throws:
IOException