Class ByteArrayRequestEntity
- java.lang.Object
-
- org.apache.commons.httpclient.methods.ByteArrayRequestEntity
-
- All Implemented Interfaces:
RequestEntity
public class ByteArrayRequestEntity extends java.lang.Object implements RequestEntity
A RequestEntity that contains an array of bytes.- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description ByteArrayRequestEntity(byte[] content)Creates a new entity with the given content.ByteArrayRequestEntity(byte[] content, java.lang.String contentType)Creates a new entity with the given content and content type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getContent()longgetContentLength()Gets the request entity's length.java.lang.StringgetContentType()Gets the entity's content type.booleanisRepeatable()Tests ifRequestEntity.writeRequest(OutputStream)can be called more than once.voidwriteRequest(java.io.OutputStream out)Writes the request entity to the given stream.
-
-
-
Constructor Detail
-
ByteArrayRequestEntity
public ByteArrayRequestEntity(byte[] content)
Creates a new entity with the given content.- Parameters:
content- The content to set.
-
ByteArrayRequestEntity
public ByteArrayRequestEntity(byte[] content, java.lang.String contentType)Creates a new entity with the given content and content type.- Parameters:
content- The content to set.contentType- The content type to set ornull.
-
-
Method Detail
-
isRepeatable
public boolean isRepeatable()
Description copied from interface:RequestEntityTests ifRequestEntity.writeRequest(OutputStream)can be called more than once.- Specified by:
isRepeatablein interfaceRequestEntity- Returns:
true
-
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)
-
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()
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
public byte[] getContent()
- Returns:
- Returns the content.
-
-