com.ning.http.client.providers.apache
Class ApacheResponseBodyPart

java.lang.Object
  extended by com.ning.http.client.HttpContent
      extended by com.ning.http.client.HttpResponseBodyPart
          extended by com.ning.http.client.providers.apache.ApacheResponseBodyPart

public class ApacheResponseBodyPart
extends HttpResponseBodyPart

A callback class used when an HTTP response body is received.


Field Summary
 
Fields inherited from class com.ning.http.client.HttpContent
provider, uri
 
Constructor Summary
ApacheResponseBodyPart(URI uri, byte[] chunk, AsyncHttpProvider provider, boolean last)
           
 
Method Summary
 boolean closeUnderlyingConnection()
          Return true of the underlying connection will be closed once the response has been fully processed.
 ByteBuffer getBodyByteBuffer()
          Return a ByteBuffer that wraps the actual bytes read from the response's chunk.
 byte[] getBodyPartBytes()
          Return the response body's part bytes received.
 boolean isLast()
          Return true if this is the last part.
 int length()
           
 void markUnderlyingConnectionAsClosed()
          Close the underlying connection once the processing has completed.
 int writeTo(OutputStream outputStream)
          Write the available bytes to the OutputStream
 
Methods inherited from class com.ning.http.client.HttpContent
getUrl, provider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApacheResponseBodyPart

public ApacheResponseBodyPart(URI uri,
                              byte[] chunk,
                              AsyncHttpProvider provider,
                              boolean last)
Method Detail

getBodyPartBytes

public byte[] getBodyPartBytes()
Return the response body's part bytes received.

Specified by:
getBodyPartBytes in class HttpResponseBodyPart
Returns:
the response body's part bytes received.

writeTo

public int writeTo(OutputStream outputStream)
            throws IOException
Description copied from class: HttpResponseBodyPart
Write the available bytes to the OutputStream

Specified by:
writeTo in class HttpResponseBodyPart
Returns:
The number of bytes written
Throws:
IOException

getBodyByteBuffer

public ByteBuffer getBodyByteBuffer()
Description copied from class: HttpResponseBodyPart
Return a ByteBuffer that wraps the actual bytes read from the response's chunk. The ByteBuffer capacity is equal to the number of bytes available.

Specified by:
getBodyByteBuffer in class HttpResponseBodyPart
Returns:
ByteBuffer

isLast

public boolean isLast()
Return true if this is the last part.

Specified by:
isLast in class HttpResponseBodyPart
Returns:
true if this is the last part.

markUnderlyingConnectionAsClosed

public void markUnderlyingConnectionAsClosed()
Close the underlying connection once the processing has completed. Invoking that method means the underlying TCP connection will be closed as soon as the processing of the response is completed. That means the underlying connection will never get pooled.

Specified by:
markUnderlyingConnectionAsClosed in class HttpResponseBodyPart

closeUnderlyingConnection

public boolean closeUnderlyingConnection()
Return true of the underlying connection will be closed once the response has been fully processed.

Specified by:
closeUnderlyingConnection in class HttpResponseBodyPart
Returns:
true of the underlying connection will be closed once the response has been fully processed.

length

public int length()
Specified by:
length in class HttpResponseBodyPart


Copyright © 2014. All Rights Reserved.