Class StringRequestEntity
java.lang.Object
org.apache.commons.httpclient.methods.StringRequestEntity
- All Implemented Interfaces:
RequestEntity
A RequestEntity that contains a String.
- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionStringRequestEntity(String content) Deprecated.StringRequestEntity(String content, String contentType, String charset) Creates a new entity with the given content, content type, and charset. -
Method Summary
Modifier and TypeMethodDescriptionlongGets the request entity's length.Gets the entity's content type.booleanTests ifRequestEntity.writeRequest(OutputStream)can be called more than once.voidwriteRequest(OutputStream out) Writes the request entity to the given stream.
-
Constructor Details
-
StringRequestEntity
Deprecated.useStringRequestEntity(String, String, String)insteadCreates a new entity with the given content. This constructor will use the default platform charset to convert the content string and will provide no content type.
- Parameters:
content- The content to set.- See Also:
-
StringRequestEntity
public StringRequestEntity(String content, String contentType, String charset) throws UnsupportedEncodingException Creates a new entity with the given content, content type, and charset.- Parameters:
content- The content to set.contentType- The type of the content, ornull. The value retured bygetContentType(). If this content type contains a charset and the charset parameter is null, the content's type charset will be used.charset- The charset of the content, ornull. Used to convert the content to bytes. If the content type does not contain a charset and charset is not null, then the charset will be appended to the content type.- Throws:
UnsupportedEncodingException
-
-
Method Details
-
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:
-
isRepeatable
public boolean isRepeatable()Description copied from interface:RequestEntityTests ifRequestEntity.writeRequest(OutputStream)can be called more than once.- Specified by:
isRepeatablein interfaceRequestEntity- Returns:
true
-
writeRequest
Description copied from interface:RequestEntityWrites the request entity to the given stream.- Specified by:
writeRequestin interfaceRequestEntity- Parameters:
out-- Throws:
IOException
-
getContentLength
public long getContentLength()Description copied from interface:RequestEntityGets the request entity's length. This method should return a non-negative value if the content length is known or a negative value if it is not. In the latter case theEntityEnclosingMethodwill use chunk encoding to transmit the request entity.- Specified by:
getContentLengthin interfaceRequestEntity- Returns:
- The length of the content.
-
getContent
- Returns:
- Returns the content.
-
getCharset
- Returns:
- Returns the charset used to convert the content to bytes.
nullif no charset as been specified.
-
StringRequestEntity(String, String, String)instead