hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38818] New: - CONNECT fails with authentication Proxy
Date Wed, 01 Mar 2006 12:50:43 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38818>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38818

           Summary: CONNECT fails with authentication Proxy
           Product: HttpClient
           Version: 3.0 Final
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Commons HttpClient
        AssignedTo: httpclient-dev@jakarta.apache.org
        ReportedBy: os@bos-bremen.de


Opening a HTTPS Connection over an authenticating Proxy (Basic auth. scheme) 
fails, if proxy credentials are not provided at the first try. 

The following example code will fail:

HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
URL url = new URL("https://examplehttpsurl");
  
//first try 
GetMethod get = new GetMethod(url.toExternalForm());
HostConfiguration hc = new HostConfiguration();
hc.setHost(url.getHost(), 443, "https");
hc.setProxy("proxyhost", 4711);

try {
  client.executeMethod(hc, get);
} catch (Exception e){
  LOG.error("",e);
} finally {
  get.releaseConnection();
}

//returns 407 (expected)
LOG.debug("Answer: " + get.getStatusLine().toString()); 

//retry with credentials (normally requested from the user)
client.getState().setProxyCredentials(new AuthScope("proxyhost",4711),
      new NTCredentials("USER", "PASS", "", ""));

get = new GetMethod(url.toExternalForm());

try {
  client.executeMethod(hc, get);
} catch (Exception e) {
  e.printStackTrace();
} finally {
  get.releaseConnection();
}
//should be 200 but is 407
LOG.debug("Answer: " + get.getStatusLine().toString());



----------


>From what I see from HttpMethodDirector.executeWithRetry(final
HttpMethod method), the cause is, that the connection is kept open, and
thus the connect is never retried:


if (!this.conn.isOpen()) {
  // this connection must be opened before it can be used
  // This has nothing to do with opening a secure tunnel
  this.conn.open();
  if (this.conn.isProxied() && this.conn.isSecure() 
      && !(method instanceof ConnectMethod)) {
    // we need to create a secure tunnel before we can execute the real method
    if (!executeConnect()) {
      // abort, the connect method failed
      return;
    }
  }
}


If I add a conn.close() before returning on !executeConnect(), the
above code will work, the CONNECT is reattempted.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message