Class InputStreamResponseListener

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Result await​(long timeout, java.util.concurrent.TimeUnit unit)
      Waits for the given timeout for the whole request/response cycle to be finished, then returns the corresponding result.
      Response get​(long timeout, java.util.concurrent.TimeUnit unit)
      Waits for the given timeout for the response to be available, then returns it.
      java.io.InputStream getInputStream()
      Returns an InputStream providing the response content bytes.
      void onComplete​(Result result)
      Callback method invoked when the request and the response have been processed, either successfully or not.
      void onContent​(Response response, java.nio.ByteBuffer content, Callback callback)
      Callback method invoked asynchronously when the response content has been received.
      void onFailure​(Response response, java.lang.Throwable failure)
      Callback method invoked when the response has failed in the process of being received
      void onHeaders​(Response response)
      Callback method invoked when the response headers have been received and parsed.
      void onSuccess​(Response response)
      Callback method invoked when the whole response has been successfully received.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InputStreamResponseListener

        public InputStreamResponseListener()
    • Method Detail

      • get

        public Response get​(long timeout,
                            java.util.concurrent.TimeUnit unit)
                     throws java.lang.InterruptedException,
                            java.util.concurrent.TimeoutException,
                            java.util.concurrent.ExecutionException
        Waits for the given timeout for the response to be available, then returns it.

        The wait ends as soon as all the HTTP headers have been received, without waiting for the content. To wait for the whole content, see await(long, TimeUnit).

        Parameters:
        timeout - the time to wait
        unit - the timeout unit
        Returns:
        the response
        Throws:
        java.lang.InterruptedException - if the thread is interrupted
        java.util.concurrent.TimeoutException - if the timeout expires
        java.util.concurrent.ExecutionException - if a failure happened
      • await

        public Result await​(long timeout,
                            java.util.concurrent.TimeUnit unit)
                     throws java.lang.InterruptedException,
                            java.util.concurrent.TimeoutException
        Waits for the given timeout for the whole request/response cycle to be finished, then returns the corresponding result.

        Parameters:
        timeout - the time to wait
        unit - the timeout unit
        Returns:
        the result
        Throws:
        java.lang.InterruptedException - if the thread is interrupted
        java.util.concurrent.TimeoutException - if the timeout expires
        See Also:
        get(long, TimeUnit)
      • getInputStream

        public java.io.InputStream getInputStream()
        Returns an InputStream providing the response content bytes.

        The method may be invoked only once; subsequent invocations will return a closed InputStream.

        Returns:
        an input stream providing the response content