You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2007/07/07 01:46:49 UTC

[HttpClient] Tunneling code appears broken by revision 542192

Roland

Secure connection tunneling appears to have been broken by the revision
542192 (proxy chains in HttpRoute/RouteTracker/RouteDirector). The code
below used to work for me. Now the same code causes an infinite loop in
the #establishRoute(HttpRoute, HttpContext) method and a stack overflow
as a result.
...
[DEBUG] wire - >> "CONNECT localhost:443 HTTP/1.1[EOL]"
[DEBUG] wire - >> "User-Agent: Jakarta-HttpClient/4.0[EOL]"
[DEBUG] wire - >> "Host: localhost:443[EOL]"
[DEBUG] wire - >> "Proxy-Authorization: Basic c3F1aWQ6c3F1aWQ=[EOL]"
[DEBUG] wire - >> "[EOL]"
[DEBUG] headers - >> CONNECT localhost:443 HTTP/1.1
[DEBUG] headers - >> User-Agent: Jakarta-HttpClient/4.0
[DEBUG] headers - >> Host: localhost:443
[DEBUG] headers - >> Proxy-Authorization: Basic c3F1aWQ6c3F1aWQ=
[DEBUG] wire - << "HTTP/1.0 200 Connection established[EOL]"
[DEBUG] headers - << HTTP/1.0 200 Connection established
[DEBUG] DefaultClientRequestDirector - Tunnel created
Exception in thread "main" java.lang.StackOverflowError

If I revert back to revision 541979, things get back to normal. There
were quite a bit of changes in that commit so it is not easy for me to
track down the cause of the problem. I'll make another attempt tomorrow.
Would you have time to take a look at it too?

Cheers

Oleg (sleepy and very tired)

-----------
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUserAgent(params, "Jakarta-HttpClient/4.0");
HttpProtocolParams.setUseExpectContinue(params, true);

DefaultHttpClient httpclient = new DefaultHttpClient(params);

KeyStore trustStore  =
KeyStore.getInstance(KeyStore.getDefaultType());        
FileInputStream instream = new FileInputStream(new
File("my.keystore")); 
try {
    trustStore.load(instream, "nopassword".toCharArray());
} finally {
    instream.close();
}

SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore);
Scheme sch = new Scheme("https", socketFactory, 443);
httpclient.getConnectionManager().getSchemeRegistry().register(sch);

httpclient.getState().setCredentials(
        new AuthScope("localhost", 443), 
        new UsernamePasswordCredentials("oleg", "oleg"));

httpclient.getState().setCredentials(
        new AuthScope("localhost", 8080), 
        new UsernamePasswordCredentials("squid", "squid"));

HttpHost targetHost = new HttpHost("localhost", 443, "https"); 
HttpHost proxy = new HttpHost("localhost", 8080); 
HttpRoute route = new HttpRoute(targetHost, null, proxy, true);

HttpGet httpget = new HttpGet("/test/");

RoutedRequest routedReq = new RoutedRequest.Impl(httpget, route); 

System.out.println("executing request: " + httpget.getRequestLine());
System.out.println("using route: " + route);

HttpResponse response = httpclient.execute(routedReq, null);
HttpEntity entity = response.getEntity();
-----------




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


Re: [HttpClient] Tunneling code appears broken by revision 542192

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2007-07-07 at 07:24 +0200, Roland Weber wrote:
> Hi Oleg,
> 
> I'll be busy during daytime. I can have a look tonight,
> or tomorrow morning at latest. I made some tweaks to
> the RouteDirector logic when I wrote the test cases.
> Could you check whether the problem was introduced
> with revision 550077?
> 
> thanks,
>   Roland
> 

Roland,

Please disregard my previous message. It was all my *STUPID* mistake.

Cheers,

Oleg


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


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


Re: [HttpClient] Tunneling code appears broken by revision 542192

Posted by Roland Weber <os...@dubioso.net>.
Hi Oleg,

I'll be busy during daytime. I can have a look tonight,
or tomorrow morning at latest. I made some tweaks to
the RouteDirector logic when I wrote the test cases.
Could you check whether the problem was introduced
with revision 550077?

thanks,
  Roland


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