On Wed, 2014-05-21 at 05:25 -0400, Bapat, Ameya wrote: > Hi all, > I have some issues with code of org.apache.http.impl.conn. > ProxySelectorRoutePlanner. > I have setup a Apache2.2 proxy for both http & https.
... > Consider my configuration in Apache-tomcat\conf\catalina.properties: > http.proxyHost=10.31.81.210 > http.proxyPort=80 > https.proxyHost=10.31.81.210 > https.proxyPort=443 > > In above code, Ideally if targetURI scheme is http then proxy should be > http://10.31.81.210:80/ & if https then it should https://10.31.81.210:443/ > but above code // assume default scheme (http) > Which is giving result as http://10.31.81.210:443 whereas actually it should > be https://10.31.81.210:443. > > HttpHost has several constructors where one of them accepts 3 parameters > which has scheme as well. > ... > > In determineProxy() code you are assuming the scheme & calling > HttpHost(final String hostname, int port) which internally passes scheme=null > and calls HttpHost(final String hostname, int port, final String scheme) > which ultimately assigns this.schemeName as http even if targetURI scheme > is https. > Finally, > I get output of > // assume default scheme (http) > > result = new HttpHost(getHost(isa), isa.getPort()); > > as result=http://10.31.81.210:443 [gives Page cannot be found because scheme > & proxy setting mismatch according to catalina.properties] > Whereas it should be result=https://10.31.81.210:443 [It works because scheme > & proxy match according to catalina.properties] > > This could be solved by replacing result = new HttpHost(getHost(isa), > isa.getPort()); by result = new HttpHost(getHost(isa), isa.getPort(), > targetURI.scheme); which is also another constructor of HttpHost. > > What is your opinion on it? > Is my doubt correct or Am I missing something ? If correct then what is the > next line of action for me as getting http instead of https is failing my web > app in presence of proxy. > Ameya HttpClient always uses plain HTTP in order to establish an initial connection with the proxy. If the target endpoint is HTTPS it then upgrades the connection using HTTP CONNECT method as described in RFC 2817 [1] Oleg [1] http://www.faqs.org/rfcs/rfc2817.html --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
