You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Thomas Vestergaard <CG...@telenor.dk> on 2012/02/29 18:19:10 UTC

Virtual host parameter on client is not inherited by requests

Hi,

When setting the virtual host parameter (ClientPNames.VIRTUAL_HOST) on a client, it has no affect on actual virtual host used when the client executes requests. It only looks at the parameters from the request object.

In version 4.2.Alpha1 this is handled in line 408-414 in org.apache.http.impl.client.DefaultRequestDirector.execute

HttpRequest orig = request;
RequestWrapper origWrapper = wrapRequest(orig);
origWrapper.setParams(params);
HttpRoute origRoute = determineRoute(target, origWrapper, context);

virtualHost = (HttpHost) orig.getParams().getParameter(
        ClientPNames.VIRTUAL_HOST);

Is this by design? Or is this a bug?

A possible solution would be to merge the two collections of parameters, but I expect, that some there needs to be a common understanding around which takes priority - parameters on client or request.

 Best regards,
Telenor

Thomas Vestergaard
Ekstern konsulent
Technology
Frederikskaj, DK-1780. København V
Tel: +45 52 18 92 18  // e-mail: cgethve@telenor.dk<ma...@telenor.dk>
Web: http://www.telenor.dk<http://www.telenor.dk/>


Re: Virtual host parameter on client is not inherited by requests

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2012-02-29 at 17:19 +0000, Thomas Vestergaard wrote:
> Hi,
> 
> When setting the virtual host parameter (ClientPNames.VIRTUAL_HOST) on a client, it has no affect on actual virtual host used when the client executes requests. It only looks at the parameters from the request object.
> 
> In version 4.2.Alpha1 this is handled in line 408-414 in org.apache.http.impl.client.DefaultRequestDirector.execute
> 
> HttpRequest orig = request;
> RequestWrapper origWrapper = wrapRequest(orig);
> origWrapper.setParams(params);
> HttpRoute origRoute = determineRoute(target, origWrapper, context);
> 
> virtualHost = (HttpHost) orig.getParams().getParameter(
>         ClientPNames.VIRTUAL_HOST);
> 
> Is this by design? Or is this a bug?
> 

This does look like a bug. Please raise a JIRA for this issue.

> A possible solution would be to merge the two collections of parameters, but I expect, that some there needs to be a common understanding around which takes priority - parameters on client or request.
> 

Request level parameters always take precedence those set at the client
level.

Oleg 

>  Best regards,
> Telenor
> 
> Thomas Vestergaard
> Ekstern konsulent
> Technology
> Frederikskaj, DK-1780. København V
> Tel: +45 52 18 92 18  // e-mail: cgethve@telenor.dk<ma...@telenor.dk>
> Web: http://www.telenor.dk<http://www.telenor.dk/>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org