Package me.desair.tus.server.util
Class HttpChunkedEncodingInputStream
java.lang.Object
java.io.InputStream
me.desair.tus.server.util.HttpChunkedEncodingInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Transparently coalesces chunks of a HTTP stream that uses Transfer-Encoding chunked. This
Based on org.apache.commons.httpclient.ChunkedInputStream
InputStream wrapper also supports collecting Trailer header values that are sent at the end of
the stream. Based on org.apache.commons.httpclient.ChunkedInputStream
-
Constructor Summary
ConstructorsConstructorDescriptionWrap the given input stream.HttpChunkedEncodingInputStream(InputStream in, Map<String, List<String>> trailerHeaders) Wrap the given input stream and store any trailing headers in the provided map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Upon close, this reads the remainder of the chunked message, leaving the underlying socket at a position to start reading the next response without scanning.intread()Reads the next byte of data from the input stream.intread(byte[] b) Read some bytes from the stream.intread(byte[] b, int off, int len) Read some bytes from the stream.Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
HttpChunkedEncodingInputStream
Wrap the given input stream and store any trailing headers in the provided map.- Parameters:
in- the raw input streamtrailerHeaders- Map to store any trailer header values. Can be null.
-
HttpChunkedEncodingInputStream
Wrap the given input stream. Do not store any trailing headers.- Parameters:
in- the raw input stream
-
-
Method Details
-
read
Reads the next byte of data from the input stream. The value byte is returned as anintin the range0to255.- Specified by:
readin classInputStream- Returns:
- -1 of the end of the stream has been reached or the next data byte
- Throws:
IOException- If an IO problem occurs
-
read
Read some bytes from the stream.- Overrides:
readin classInputStream- Parameters:
b- The byte array that will hold the contents from the stream.off- The offset into the byte array at which bytes will start to be placed.len- the maximum number of bytes that can be returned.- Returns:
- The number of bytes returned or -1 if the end of stream has been reached.
- Throws:
IOException- if an IO problem occurs.- See Also:
-
read
Read some bytes from the stream.- Overrides:
readin classInputStream- Parameters:
b- The byte array that will hold the contents from the stream.- Returns:
- The number of bytes returned or -1 if the end of stream has been reached.
- Throws:
IOException- if an IO problem occurs.- See Also:
-
close
Upon close, this reads the remainder of the chunked message, leaving the underlying socket at a position to start reading the next response without scanning.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- If an IO problem occurs.
-