[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-commons-dev
Subject:    [jira] Resolved: (HTTPCLIENT-541) Redesign virtual host API
From:       "Oleg Kalnichevski (JIRA)" <jira () apache ! org>
Date:       2007-05-21 18:39:16
Message-ID: 23538981.1179772756199.JavaMail.jira () brutus
[Download RAW message or body]


     [ https://issues.apache.org/jira/browse/HTTPCLIENT-541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]

Oleg Kalnichevski resolved HTTPCLIENT-541.
------------------------------------------

    Resolution: Fixed

HttpClient 4.0 API now provides several ways of dealing with virtual hosts:
(1) by providing a custom protocol interceptor intended to generate the 'Host' \
request header (2) by setting a virtual host parameter in HttpParams 

Oleg

> Redesign virtual host API
> -------------------------
> 
> Key: HTTPCLIENT-541
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-541
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: Nightly Builds
> Environment: Operating System: other
> Platform: Other
> Reporter: Peter Bryant
> Priority: Minor
> Fix For: 4.0 Alpha 1
> 
> 
> HttpClient is ignoring an explicity set host.  e.g. if you set the host like
> client.getHostConfiguration().setHost("127.0.0.1") then execute a method looking
> up say http://google.com then the program will connect to google.com rather than
> the localhost.
> The fix that works for me:
> diff -Naur
> ../../t2/commons-httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
> src/java/org/apache/commons/httpclient/HttpClient.java
> ---
> ../../t2/commons-httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
> 2005-12-22 01:06:54.000000000 +1300
> +++ src/java/org/apache/commons/httpclient/HttpClient.java	2005-12-22
> 19:13:30.000000000 +1300
> @@ -383,7 +383,9 @@
> if (hostconfig == defaulthostconfig || uri.isAbsoluteURI()) {
> // make a deep copy of the host defaults
> hostconfig = new HostConfiguration(hostconfig);
> -            if (uri.isAbsoluteURI()) {
> +	    // if the host is explicity set already (e.g. to the IP of the virtual host
> +	    // on which we are executing a method), just leave it
> +            if (uri.isAbsoluteURI()  && hostconfig.getHost()==null) {
> hostconfig.setHost(uri);
> }
> Note: Why do we care that the host is specified?  Why not just use the uri
> authority?  In my case I have a virtual host running on several servers/IPs and
> I need to make sure the request goes through to a specific IP and the response
> that comes back is for the virtual host I am testing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic