Package org.asynchttpclient.handler
Class BodyDeferringAsyncHandler.BodyDeferringInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.asynchttpclient.handler.BodyDeferringAsyncHandler.BodyDeferringInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- 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
Constructors Constructor Description BodyDeferringInputStream(Future<Response> future, BodyDeferringAsyncHandler bdah, InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the input stream, and "joins" (wait for complete execution together with potential exception thrown) of the async request.@Nullable Response
getAsapResponse()
Delegates toBodyDeferringAsyncHandler.getResponse()
.Response
getLastResponse()
Delegates toFuture$lt;Response>#get()
method.-
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
BodyDeferringInputStream
public 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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
-
getAsapResponse
@Nullable public @Nullable Response getAsapResponse() throws InterruptedException, IOException
Delegates toBodyDeferringAsyncHandler.getResponse()
. Will blocks as long as headers arrives only. Might returnnull
. SeeBodyDeferringAsyncHandler.getResponse()
method for details.- Returns:
- a
Response
- Throws:
InterruptedException
- if the latch is interruptedIOException
- if the handler completed with an exception
-
getLastResponse
public Response getLastResponse() throws InterruptedException, ExecutionException
Delegates toFuture$lt;Response>#get()
method. Will block as long as complete response arrives.- Returns:
- a
Response
- Throws:
ExecutionException
- if the computation threw an exceptionInterruptedException
- if the current thread was interrupted
-
-