org.apache.commons.httpclient.methods

Class ByteArrayRequestEntity

Implemented Interfaces:
RequestEntity

public class ByteArrayRequestEntity
extends Object
implements RequestEntity

A RequestEntity that contains an array of bytes.

Since:
3.0

Constructor Summary

ByteArrayRequestEntity(byte[] content)
Creates a new entity with the given content.
ByteArrayRequestEntity(byte[] content, String contentType)
Creates a new entity with the given content and content type.

Method Summary

byte[]
getContent()
long
getContentLength()
String
getContentType()
Gets the entity's content type.
boolean
isRepeatable()
void
writeRequest(OutputStream out)
Writes the request entity to the given stream.

Constructor Details

ByteArrayRequestEntity

public ByteArrayRequestEntity(byte[] content)
Creates a new entity with the given content.

Parameters:
content - The content to set.


ByteArrayRequestEntity

public ByteArrayRequestEntity(byte[] content,
                              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 or null.

Method Details

getContent

public byte[] getContent()

Returns:
Returns the content.


getContentLength

public long getContentLength()
Specified by:
getContentLength in interface RequestEntity

Returns:
The length of the content.


getContentType

public String getContentType()
Gets the entity's content type. This content type will be used as the value for the "Content-Type" header.
Specified by:
getContentType in interface RequestEntity

Returns:
the entity's content type

See Also:
HttpMethod.setRequestHeader(String,String)


isRepeatable

public boolean isRepeatable()
Specified by:
isRepeatable in interface RequestEntity

Returns:
true


writeRequest

public void writeRequest(OutputStream out)
            throws IOException
Writes the request entity to the given stream.
Specified by:
writeRequest in interface RequestEntity

Parameters:
out -


Copyright (c) 1999-2005 - Apache Software Foundation