Class StreamedHttpContent
- java.lang.Object
-
- net.lenni0451.commons.httpclient.content.HttpContent
-
- net.lenni0451.commons.httpclient.content.StreamedHttpContent
-
public class StreamedHttpContent extends HttpContent
Represents a streamed http content which is not fully loaded into memory.
It requires special handling in the executor to support this type of content.
It is fully backwards compatible if the executor does not support this feature by reading the entire stream into memory.
All built-in executors support this type of content.
-
-
Field Summary
-
Fields inherited from class net.lenni0451.commons.httpclient.content.HttpContent
content
-
-
Constructor Summary
Constructors Constructor Description StreamedHttpContent(ContentType contentType, java.io.InputStream inputStream, int contentLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]compute()intgetBufferSize()intgetContentLength()java.io.InputStreamgetInputStream()StreamedHttpContentsetBufferSize(int bufferSize)Set the buffer size for reading the stream.
This option may be ignored depending on the executor implementation.-
Methods inherited from class net.lenni0451.commons.httpclient.content.HttpContent
bytes, bytes, file, form, form, getAsBytes, getAsString, getAsString, getContentType, multiPartForm, streamed, string, string
-
-
-
-
Constructor Detail
-
StreamedHttpContent
public StreamedHttpContent(ContentType contentType, java.io.InputStream inputStream, int contentLength)
-
-
Method Detail
-
getInputStream
public java.io.InputStream getInputStream()
- Returns:
- The input stream
-
getBufferSize
public int getBufferSize()
- Returns:
- The buffer size for reading the stream
-
setBufferSize
public StreamedHttpContent setBufferSize(int bufferSize)
Set the buffer size for reading the stream.
This option may be ignored depending on the executor implementation.- Parameters:
bufferSize- The buffer size- Returns:
- This instance for chaining
-
getContentLength
public int getContentLength()
- Specified by:
getContentLengthin classHttpContent- Returns:
- The content length
-
compute
@Nonnull protected byte[] compute() throws java.io.IOException- Specified by:
computein classHttpContent- Returns:
- The content
- Throws:
java.io.IOException- If an I/O error occurs
-
-