On Mon, 2010-12-06 at 20:39 +0000, sebb wrote:
> I'm following the example in the HttpClient documentation:
>
> DefaultHttpClient httpclient = new DefaultHttpClient();
> HttpContext localContext = new BasicHttpContext();
> HttpGet httpget = new HttpGet("http://www.google.com/");
> HttpResponse response = httpclient.execute(httpget, localContext);
> HttpHost target = (HttpHost) localContext.getAttribute(
> ExecutionContext.HTTP_TARGET_HOST);
> HttpUriRequest req = (HttpUriRequest) localContext.getAttribute(
> ExecutionContext.HTTP_REQUEST);
> System.out.println("Target host: " + target);
> System.out.println("Final request URI: " + req.getURI());
>
> I see the following output:
>
> Target host: http://www.google.co.uk
> Final request URI: /
>
> However, I would expect to see an absolute URI, as per the Javadoc for
> HttpUriRequest#getURI().
>
> Is this a bug in the Javadoc (and user guide?) or a bug in the code?
>
Hi Sebastian
I could find any passage in javadocs or tutorial stating such
requirement. As far as I remember request URIs can be either absolute or
relative. In case of a relative request URI HttpClient attempts to
determine the target host based on request parameters. In case of a
absolute request URI HttpClient rewrites the request URI as relative and
adds a 'Host' header containing the target host.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]