public class

BasicManagedEntity

extends HttpEntityWrapper
implements ConnectionReleaseTrigger EofSensorWatcher
java.lang.Object
   ↳ org.apache.http.entity.HttpEntityWrapper
     ↳ org.apache.http.conn.BasicManagedEntity

Class Overview

An entity that releases a connection. A ManagedClientConnection will typically not return a managed entity, but you can replace the unmanaged entity in the response with a managed one.

Summary

Fields
protected final boolean attemptReuse Whether to keep the connection alive.
protected ManagedClientConnection managedConn The connection to release.
[Expand]
Inherited Fields
From class org.apache.http.entity.HttpEntityWrapper
Public Constructors
BasicManagedEntity(HttpEntity entity, ManagedClientConnection conn, boolean reuse)
Creates a new managed entity that can release a connection.
Public Methods
void abortConnection()
Releases the connection without the option of keep-alive.
void consumeContent()
boolean eofDetected(InputStream wrapped)
Indicates that EOF is detected.
InputStream getContent()
boolean isRepeatable()
void releaseConnection()
Releases the connection with the option of keep-alive.
boolean streamAbort(InputStream wrapped)
Indicates that the stream is aborted.
boolean streamClosed(InputStream wrapped)
Indicates that the stream is closed.
void writeTo(OutputStream outstream)
Protected Methods
void releaseManagedConnection()
Releases the connection gracefully.
[Expand]
Inherited Methods
From class org.apache.http.entity.HttpEntityWrapper
From class java.lang.Object
From interface org.apache.http.HttpEntity
From interface org.apache.http.conn.ConnectionReleaseTrigger
From interface org.apache.http.conn.EofSensorWatcher

Fields

protected final boolean attemptReuse

Also: HttpClient

Whether to keep the connection alive.

protected ManagedClientConnection managedConn

Also: HttpClient

The connection to release.

Public Constructors

public BasicManagedEntity (HttpEntity entity, ManagedClientConnection conn, boolean reuse)

Also: HttpClient

Creates a new managed entity that can release a connection.

Parameters
entity the entity of which to wrap the content. Note that the argument entity can no longer be used afterwards, since the content will be taken by this managed entity.
conn the connection to release
reuse whether the connection should be re-used

Public Methods

public void abortConnection ()

Also: HttpClient

Releases the connection without the option of keep-alive. This is a "hard" release that implies a shutdown of the connection. Use releaseConnection() for a graceful release.

Throws
IOException

public void consumeContent ()

Throws
IOException

public boolean eofDetected (InputStream wrapped)

Also: HttpClient

Indicates that EOF is detected.

Parameters
wrapped the underlying stream which has reached EOF
Returns
  • true if wrapped should be closed, false if it should be left alone
Throws
IOException

public InputStream getContent ()

Throws
IOException

public boolean isRepeatable ()

public void releaseConnection ()

Also: HttpClient

Releases the connection with the option of keep-alive. This is a "graceful" release and may cause IO operations for consuming the remainder of a response entity. Use abortConnection for a hard release. The connection may be reused as specified by the duration.

Throws
IOException

public boolean streamAbort (InputStream wrapped)

Also: HttpClient

Indicates that the stream is aborted. This method will be called only if EOF was not detected before aborting. Otherwise, eofDetected is called.

This method will also be invoked when an input operation causes an IOException to be thrown to make sure the input stream gets shut down.

Parameters
wrapped the underlying stream which has not reached EOF
Returns
  • true if wrapped should be closed, false if it should be left alone
Throws
IOException

public boolean streamClosed (InputStream wrapped)

Also: HttpClient

Indicates that the stream is closed. This method will be called only if EOF was not detected before closing. Otherwise, eofDetected is called.

Parameters
wrapped the underlying stream which has not reached EOF
Returns
  • true if wrapped should be closed, false if it should be left alone
Throws
IOException

public void writeTo (OutputStream outstream)

Throws
IOException

Protected Methods

protected void releaseManagedConnection ()

Also: HttpClient

Releases the connection gracefully. The connection attribute will be nullified. Subsequent invocations are no-ops.

Throws
IOException in case of an IO problem. The connection attribute will be nullified anyway.