Interface AsyncHandler<T>

    • Method Detail

      • onStatusReceived

        AsyncHandler.State onStatusReceived​(HttpResponseStatus responseStatus)
                                     throws Exception
        Invoked as soon as the HTTP status line has been received
        Parameters:
        responseStatus - the status code and test of the response
        Returns:
        a AsyncHandler.State telling to CONTINUE or ABORT the current processing.
        Throws:
        Exception - if something wrong happens
      • onHeadersReceived

        AsyncHandler.State onHeadersReceived​(io.netty.handler.codec.http.HttpHeaders headers)
                                      throws Exception
        Invoked as soon as the HTTP headers have been received.
        Parameters:
        headers - the HTTP headers.
        Returns:
        a AsyncHandler.State telling to CONTINUE or ABORT the current processing.
        Throws:
        Exception - if something wrong happens
      • onBodyPartReceived

        AsyncHandler.State onBodyPartReceived​(HttpResponseBodyPart bodyPart)
                                       throws Exception
        Invoked as soon as some response body part are received. Could be invoked many times. Beware that, depending on the provider (Netty) this can be notified with empty body parts.
        Parameters:
        bodyPart - response's body part.
        Returns:
        a AsyncHandler.State telling to CONTINUE or ABORT the current processing. Aborting will also close the connection.
        Throws:
        Exception - if something wrong happens
      • onTrailingHeadersReceived

        default AsyncHandler.State onTrailingHeadersReceived​(io.netty.handler.codec.http.HttpHeaders headers)
                                                      throws Exception
        Invoked when trailing headers have been received.
        Parameters:
        headers - the trailing HTTP headers.
        Returns:
        a AsyncHandler.State telling to CONTINUE or ABORT the current processing.
        Throws:
        Exception - if something wrong happens
      • onThrowable

        void onThrowable​(Throwable t)
        Invoked when an unexpected exception occurs during the processing of the response. The exception may have been produced by implementation of onXXXReceived method invocation.
        Parameters:
        t - a Throwable
      • onCompleted

        T onCompleted()
               throws Exception
        Invoked once the HTTP response processing is finished.
        Gets always invoked as last callback method.
        Returns:
        T Value that will be returned by the associated Future
        Throws:
        Exception - if something wrong happens
      • onHostnameResolutionAttempt

        default void onHostnameResolutionAttempt​(String name)
        Notify the callback before hostname resolution
        Parameters:
        name - the name to be resolved
      • onHostnameResolutionSuccess

        default void onHostnameResolutionSuccess​(String name,
                                                 List<InetSocketAddress> addresses)
        Notify the callback after hostname resolution was successful.
        Parameters:
        name - the name to be resolved
        addresses - the resolved addresses
      • onHostnameResolutionFailure

        default void onHostnameResolutionFailure​(String name,
                                                 Throwable cause)
        Notify the callback after hostname resolution failed.
        Parameters:
        name - the name to be resolved
        cause - the failure cause
      • onTcpConnectAttempt

        default void onTcpConnectAttempt​(InetSocketAddress remoteAddress)
        Notify the callback when trying to open a new connection.

        Might be called several times if the name was resolved to multiple addresses and we failed to connect to the first(s) one(s).

        Parameters:
        remoteAddress - the address we try to connect to
      • onTcpConnectSuccess

        default void onTcpConnectSuccess​(InetSocketAddress remoteAddress,
                                         io.netty.channel.Channel connection)
        Notify the callback after a successful connect
        Parameters:
        remoteAddress - the address we try to connect to
        connection - the connection
      • onTcpConnectFailure

        default void onTcpConnectFailure​(InetSocketAddress remoteAddress,
                                         Throwable cause)
        Notify the callback after a failed connect.

        Might be called several times, or be followed by onTcpConnectSuccess when the name was resolved to multiple addresses.

        Parameters:
        remoteAddress - the address we try to connect to
        cause - the cause of the failure
      • onTlsHandshakeAttempt

        default void onTlsHandshakeAttempt()
        Notify the callback before TLS handshake
      • onTlsHandshakeSuccess

        default void onTlsHandshakeSuccess​(SSLSession sslSession)
        Notify the callback after the TLS was successful
      • onTlsHandshakeFailure

        default void onTlsHandshakeFailure​(Throwable cause)
        Notify the callback after the TLS failed
        Parameters:
        cause - the cause of the failure
      • onConnectionPoolAttempt

        default void onConnectionPoolAttempt()
        Notify the callback when trying to fetch a connection from the pool.
      • onConnectionPooled

        default void onConnectionPooled​(io.netty.channel.Channel connection)
        Notify the callback when a new connection was successfully fetched from the pool.
        Parameters:
        connection - the connection
      • onConnectionOffer

        default void onConnectionOffer​(io.netty.channel.Channel connection)
        Notify the callback when trying to offer a connection to the pool.
        Parameters:
        connection - the connection
      • onRequestSend

        default void onRequestSend​(NettyRequest request)
        Notify the callback when a request is being written on the channel. If the original request causes multiple requests to be sent, for example, because of authorization or retry, it will be notified multiple times.
        Parameters:
        request - the real request object as passed to the provider
      • onRetry

        default void onRetry()
        Notify the callback every time a request is being retried.