public class

BasicHttpEntity

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

Class Overview

A generic streamed entity being received on a connection.

Summary

[Expand]
Inherited Fields
From class org.apache.http.entity.AbstractHttpEntity
Public Constructors
BasicHttpEntity()
Creates a new basic entity.
Public Methods
void consumeContent()
Does not consume anything.
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 ()

Since: API Level 1

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

Public Methods

public void consumeContent ()

Since: API Level 1

Does not consume anything. The default implementation does nothing if isStreaming returns false, and throws an exception if it returns true. This removes the burden of implementing an empty method for non-streaming entities.

Throws
IOException

public InputStream getContent ()

Since: API Level 1

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 been obtained before, or has not yet been provided

public long getContentLength ()

Since: API Level 1

public boolean isRepeatable ()

Since: API Level 1

Tells that this entity is not repeatable.

Returns
  • false

public boolean isStreaming ()

Since: API Level 1

public void setContent (InputStream instream)

Since: API Level 1

Specifies the content.

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

public void setContentLength (long len)

Since: API Level 1

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)

Since: API Level 1

Throws
IOException