com.ning.http.client
Class BodyDeferringAsyncHandler.BodyDeferringInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.ning.http.client.BodyDeferringAsyncHandler.BodyDeferringInputStream
All Implemented Interfaces:
java.io.Closeable
Enclosing class:
BodyDeferringAsyncHandler

public static class BodyDeferringAsyncHandler.BodyDeferringInputStream
extends java.io.FilterInputStream

A simple helper class that is used to perform automatic "join" for async download and the error checking of the Future of the request.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
BodyDeferringAsyncHandler.BodyDeferringInputStream(java.util.concurrent.Future<Response> future, BodyDeferringAsyncHandler bdah, java.io.InputStream in)
           
 
Method Summary
 void close()
          Closes the input stream, and "joins" (wait for complete execution together with potential exception thrown) of the async request.
 Response getAsapResponse()
          Delegates to BodyDeferringAsyncHandler.getResponse().
 Response getLastResponse()
          Delegates to Future#get() method.
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BodyDeferringAsyncHandler.BodyDeferringInputStream

public BodyDeferringAsyncHandler.BodyDeferringInputStream(java.util.concurrent.Future<Response> future,
                                                          BodyDeferringAsyncHandler bdah,
                                                          java.io.InputStream in)
Method Detail

close

public void close()
           throws java.io.IOException
Closes the input stream, and "joins" (wait for complete execution together with potential exception thrown) of the async request.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterInputStream
Throws:
java.io.IOException

getAsapResponse

public Response getAsapResponse()
                         throws java.lang.InterruptedException,
                                java.io.IOException
Delegates to BodyDeferringAsyncHandler.getResponse(). Will blocks as long as headers arrives only. Might return null. See BodyDeferringAsyncHandler.getResponse() method for details.

Returns:
a Response
Throws:
java.lang.InterruptedException
java.io.IOException

getLastResponse

public Response getLastResponse()
                         throws java.lang.InterruptedException,
                                java.util.concurrent.ExecutionException
Delegates to Future#get() method. Will block as long as complete response arrives.

Returns:
a Response
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException


Copyright © 2011. All Rights Reserved.