-
- All Implemented Interfaces:
public interface DefaultHttpClient.CallbackCallbacks allowing to override some behavior of the DefaultHttpClient.
-
-
Method Summary
Modifier and Type Method Description Try<HttpRequest, HttpException>onStartRequest(HttpRequest request)Called when the HTTP client will start a new request. Try<HttpRequest, HttpException>onRecoverRequest(HttpRequest request, HttpException error)Called when the HTTP client received an error for the given request, to provide an opportunity to the implementer to recover from it. Try<HttpRequest, HttpException>onFollowUnsafeRedirect(HttpRequest request, HttpResponse response, HttpRequest newRequest)Redirections are followed by default when the host and protocols are the same. UnitonResponseReceived(HttpRequest request, HttpResponse response)Called when the HTTP client received an HTTP response for the given request. UnitonRequestFailed(HttpRequest request, HttpException error)Called when the HTTP client received an error for the given request. -
-
Method Detail
-
onStartRequest
Try<HttpRequest, HttpException> onStartRequest(HttpRequest request)
-
onRecoverRequest
Try<HttpRequest, HttpException> onRecoverRequest(HttpRequest request, HttpException error)
Called when the HTTP client received an error for the given request, to provide an opportunity to the implementer to recover from it.
You can return either:
a new recovery request to start
the error argument, if you cannot recover from it
a new HttpException to provide additional information
-
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:
the provided newRequest to proceed with the redirection
a different redirection request
a HttpException.CANCELLED error to abort the redirection
-
onResponseReceived
Unit onResponseReceived(HttpRequest request, HttpResponse response)
-
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.
-
-
-
-