Stuart White wrote:
Then what is the appropriate way for me to determine where a request
was redirected to, regardless of whether it went through a proxy?
Thanks!
Here's what you do:
private static URI getLocation(HttpContext context)
throws URISyntaxException {
HttpUriRequest finalRequest = (HttpUriRequest) context
.getAttribute(ExecutionContext.HTTP_REQUEST);
HttpHost target = (HttpHost) context
.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
URI uri = finalRequest.getURI();
if (!uri.isAbsolute()) {
uri = URIUtils.rewriteURI(uri, target);
}
return uri;
}
On Fri, Dec 19, 2008 at 7:51 AM, Oleg Kalnichevski <[email protected]> wrote:
On Wed, 2008-12-17 at 13:34 -0600, Stuart White wrote:
The behavior of HttpUriRequest.getURI() seems to be inconsistent,
depending on whether the request goes through a proxy or not.
For this example, I'm attempting to access http://zeroc.com/download.html.
Please see the attached source code. If I run this source code with
no proxy configured, getURI() returns:
/download.html
However, if I change the code to use a proxy, getURI() now returns:
http://zeroc.com/download.html
I've tested this both with the latest releases of httpcore and
httpclient as well as subversion revision 727427, and this behavior
occurs regardless.
Is this expected behavior?
Yes, it is. The URI of the request object corresponds to the Request-URI
of the HTTP message. It is expected to be relative for direct requests
and absolute for proxied ones.
Hope this helps
Oleg
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]