Class InputStreamRequestEntity
- java.lang.Object
-
- org.apache.commons.httpclient.methods.InputStreamRequestEntity
-
- All Implemented Interfaces:
RequestEntity
public class InputStreamRequestEntity extends java.lang.Object implements RequestEntity
A RequestEntity that contains an InputStream.- Since:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description static intCONTENT_LENGTH_AUTOThe content length will be calculated automatically.
-
Constructor Summary
Constructors Constructor Description InputStreamRequestEntity(java.io.InputStream content)Creates a new InputStreamRequestEntity with the given content and a content type ofCONTENT_LENGTH_AUTO.InputStreamRequestEntity(java.io.InputStream content, long contentLength)Creates a new InputStreamRequestEntity with the given content and content length.InputStreamRequestEntity(java.io.InputStream content, long contentLength, java.lang.String contentType)Creates a new InputStreamRequestEntity with the given content, content length, and content type.InputStreamRequestEntity(java.io.InputStream content, java.lang.String contentType)Creates a new InputStreamRequestEntity with the given content, content type, and a content length ofCONTENT_LENGTH_AUTO.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamgetContent()longgetContentLength()Gets the content length.java.lang.StringgetContentType()Gets the entity's content type.booleanisRepeatable()Tests if this method is repeatable.voidwriteRequest(java.io.OutputStream out)Writes the request entity to the given stream.
-
-
-
Field Detail
-
CONTENT_LENGTH_AUTO
public static final int CONTENT_LENGTH_AUTO
The content length will be calculated automatically. This implies buffering of the content.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InputStreamRequestEntity
public InputStreamRequestEntity(java.io.InputStream content)
Creates a new InputStreamRequestEntity with the given content and a content type ofCONTENT_LENGTH_AUTO.- Parameters:
content- The content to set.
-
InputStreamRequestEntity
public InputStreamRequestEntity(java.io.InputStream content, java.lang.String contentType)Creates a new InputStreamRequestEntity with the given content, content type, and a content length ofCONTENT_LENGTH_AUTO.- Parameters:
content- The content to set.contentType- The type of the content, ornull.
-
InputStreamRequestEntity
public InputStreamRequestEntity(java.io.InputStream content, long contentLength)Creates a new InputStreamRequestEntity with the given content and content length.- Parameters:
content- The content to set.contentLength- The content size in bytes or a negative number if not known. IfCONTENT_LENGTH_AUTOis given the content will be buffered in order to determine its size whengetContentLength()is called.
-
InputStreamRequestEntity
public InputStreamRequestEntity(java.io.InputStream content, long contentLength, java.lang.String contentType)Creates a new InputStreamRequestEntity with the given content, content length, and content type.- Parameters:
content- The content to set.contentLength- The content size in bytes or a negative number if not known. IfCONTENT_LENGTH_AUTOis given the content will be buffered in order to determine its size whengetContentLength()is called.contentType- The type of the content, ornull.
-
-
Method Detail
-
getContentType
public java.lang.String getContentType()
Description copied from interface:RequestEntityGets the entity's content type. This content type will be used as the value for the "Content-Type" header.- Specified by:
getContentTypein interfaceRequestEntity- Returns:
- the entity's content type
- See Also:
HttpMethod.setRequestHeader(String, String)
-
isRepeatable
public boolean isRepeatable()
Tests if this method is repeatable. Onlytrueif the content has been buffered.- Specified by:
isRepeatablein interfaceRequestEntity- Returns:
- true if the entity can be written to
OutputStreammore than once, false otherwise. - See Also:
getContentLength()
-
writeRequest
public void writeRequest(java.io.OutputStream out) throws java.io.IOExceptionDescription copied from interface:RequestEntityWrites the request entity to the given stream.- Specified by:
writeRequestin interfaceRequestEntity- Throws:
java.io.IOException
-
getContentLength
public long getContentLength()
Gets the content length. If the content length has not been set, the content will be buffered to determine the actual content length.- Specified by:
getContentLengthin interfaceRequestEntity- Returns:
- a non-negative value when content length is known or a negative value when content length is not known
-
getContent
public java.io.InputStream getContent()
- Returns:
- Returns the content.
-
-