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:
Closeable
Enclosing class:
BodyDeferringAsyncHandler

public static class BodyDeferringAsyncHandler.BodyDeferringInputStream
extends 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(Future<Response> future, BodyDeferringAsyncHandler bdah, 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(Future<Response> future,
                                                          BodyDeferringAsyncHandler bdah,
                                                          InputStream in)
Method Detail

close

public void close()
           throws 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 Closeable
Overrides:
close in class FilterInputStream
Throws:
IOException

getAsapResponse

public Response getAsapResponse()
                         throws InterruptedException,
                                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:
InterruptedException
IOException

getLastResponse

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

Returns:
a Response
Throws:
InterruptedException
ExecutionException


Copyright © 2011. All Rights Reserved.