public class

BasicHttpEntity

extends AbstractHttpEntity
java.lang.Object
   ↳ org.apache.http.entity.AbstractHttpEntity
     ↳ org.apache.http.entity.BasicHttpEntity

Class Overview

A generic streamed, non-repeatable entity that obtains its content from an InputStream.

Summary

[Expand]
Inherited Fields
From class org.apache.http.entity.AbstractHttpEntity
Public Constructors
BasicHttpEntity()
Creates a new basic entity.
Public Methods
void consumeContent()
This method is deprecated. Either use getContent() and call close() on that; otherwise call writeTo(OutputStream) which is required to free the resources.
InputStream getContent()
Obtains the content, once only.
long getContentLength()
boolean isRepeatable()
Tells that this entity is not repeatable.
boolean isStreaming()
void setContent(InputStream instream)
Specifies the content.
void setContentLength(long len)
Specifies the length of the content.
void writeTo(OutputStream outstream)
[Expand]
Inherited Methods
From class org.apache.http.entity.AbstractHttpEntity
From class java.lang.Object
From interface org.apache.http.HttpEntity

Public Constructors

public BasicHttpEntity ()

Creates a new basic entity. The content is initially missing, the content length is set to a negative number.

Public Methods

public void consumeContent ()

This method is deprecated.
Either use getContent() and call close() on that; otherwise call writeTo(OutputStream) which is required to free the resources.

Closes the content InputStream.

Throws
IOException

public InputStream getContent ()

Obtains the content, once only.

Returns
  • the content, if this is the first call to this method since setContent has been called
Throws
IllegalStateException if the content has not been provided

public long getContentLength ()

public boolean isRepeatable ()

Tells that this entity is not repeatable.

Returns
  • false

public boolean isStreaming ()

public void setContent (InputStream instream)

Specifies the content.

Parameters
instream the stream to return with the next call to getContent

public void setContentLength (long len)

Specifies the length of the content.

Parameters
len the number of bytes in the content, or a negative number to indicate an unknown length

public void writeTo (OutputStream outstream)

Throws
IOException