Package 

Interface DefaultHttpClient.Callback

    • Constructor Detail

    • Method Detail

      • onFollowUnsafeRedirect

         Try<HttpRequest, HttpException> onFollowUnsafeRedirect(HttpRequest request, HttpResponse response, HttpRequest newRequest)

        Redirections are followed by default when the host and protocols are the same. However, if for example an HTTP server redirects to an HTTPS URI, you will need to confirm explicitly the redirection by implementing this callback as it is potentially unsafe.

        It's recommended to confirm the redirection with the user, especially for a POST request.

        You can return either:

      • onResponseReceived

         Unit onResponseReceived(HttpRequest request, HttpResponse response)

        Called when the HTTP client received an HTTP response for the given request.

        You do not need to do anything with this response, which the HTTP client will handle. This is merely for informational purposes. For example, you could implement this to confirm that request credentials were successful.

      • onRequestFailed

         Unit onRequestFailed(HttpRequest request, HttpException error)

        Called when the HTTP client received an error for the given request.

        You do not need to do anything with this error, which the HTTP client will handle. This is merely for informational purposes.

        This will be called only if onRecoverRequest is not implemented, or returns an error.