I have the following scenario:
Android HttpClient is redirected to alternative location, the redirection url comes back with a certain url parameter which has to be propagated as extra http header in the redirection request. The only way to interfere is to override the DefaultRedirectHandler.getLocationURI handler. Now my question: how within
public URI getLocationURI(HttpResponse response, HttpContext context)
I can modify the out-coming request.
You have to create an implementation of RedirectHandler and overwrite getLocationURI(). You can get the redirect url by
Header locationHeader = response.getFirstHeader("location");
String location = locationHeader.getValue();
extract your url parameter from location and then you could get the HttpRequest by
BasicHttpRequest request = (BasicHttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
header.addHeader();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With