You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Thomas Mathis (JIRA)" <ji...@apache.org> on 2007/04/17 14:13:15 UTC

[jira] Created: (HTTPCLIENT-646) HttpClient.executeMethod with absolute URI removes the Protocol from the hostConfiguration

HttpClient.executeMethod with absolute URI removes the Protocol from the hostConfiguration
------------------------------------------------------------------------------------------

                 Key: HTTPCLIENT-646
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-646
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient
    Affects Versions: 3.1 RC1
            Reporter: Thomas Mathis


Testprogram (snippet):

public void test() throws IOException 
{
  String url = "https://www.somehost.com/somepath";
  URL u = new URL(url);
  Protocol protocol = new Protocol("https", new AcceptAllSSLProtocolSocketFactory(), port);
  HttpClient httpClient = new HttpClient();
  httpClient.getHostConfiguration().setHost(u.getHost(), port, protocol);
  GetMethod m = new GetMethod(url);
  httpClient.httpClient.executeMethod(m);
  System.out.println("status=" + m.getStatusCode());
}

Suggested fix in method public int executeMethod(HostConfiguration hostconfig, final HttpMethod method, final HttpState state)

....
// make a deep copy of the host defaults
hostconfig = (HostConfiguration) hostconfig.clone();
if (uri.isAbsoluteURI()) {
    //hostconfig.setHost(uri); <-- this line replaces the Protocol with the default one
    hostconfig.setHost(uri.getHost(), uri.getPort(), hostconfig.getProtocol());
}
....



-- 
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


[jira] Resolved: (HTTPCLIENT-646) HttpClient.executeMethod with absolute URI removes the Protocol from the hostConfiguration

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCLIENT-646.
------------------------------------------

    Resolution: Invalid

Thomas,

This is the expected behavior. Please _always_ use a relative request URI when providing a custom HostConfiguration as a parameter to HttpClient#executeMethod. For an alternative solution please refer to HTTPCLIENT-634

Oleg

> HttpClient.executeMethod with absolute URI removes the Protocol from the hostConfiguration
> ------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-646
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-646
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 3.1 RC1
>            Reporter: Thomas Mathis
>
> Testprogram (snippet):
> public void test() throws IOException 
> {
>   String url = "https://www.somehost.com/somepath";
>   URL u = new URL(url);
>   Protocol protocol = new Protocol("https", new AcceptAllSSLProtocolSocketFactory(), port);
>   HttpClient httpClient = new HttpClient();
>   httpClient.getHostConfiguration().setHost(u.getHost(), port, protocol);
>   GetMethod m = new GetMethod(url);
>   httpClient.httpClient.executeMethod(m);
>   System.out.println("status=" + m.getStatusCode());
> }
> Suggested fix in method public int executeMethod(HostConfiguration hostconfig, final HttpMethod method, final HttpState state)
> ....
> // make a deep copy of the host defaults
> hostconfig = (HostConfiguration) hostconfig.clone();
> if (uri.isAbsoluteURI()) {
>     //hostconfig.setHost(uri); <-- this line replaces the Protocol with the default one
>     hostconfig.setHost(uri.getHost(), uri.getPort(), hostconfig.getProtocol());
> }
> ....

-- 
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