[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17109598#comment-17109598
 ] 

Michael Osipov commented on HTTPCLIENT-1966:
--------------------------------------------

I woudn't mind to perform a 4.5.x release in near future. I always wanted to 
performs the entire procedure once because I an only acquire with the process 
from the Maven community only.

> System Proxy - HTTP and SOCKS
> -----------------------------
>
>                 Key: HTTPCLIENT-1966
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1966
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (Windows)
>    Affects Versions: 4.5.5, 4.5.6
>            Reporter: Mikolaj Broniszewski
>            Priority: Major
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> Hello,
> I have created a proxy server basing on squid solution. And I have hidden the 
> server (Apache Tomcat 8) which I would like to access behind this proxy (it's 
> not available from my local machine directly). Then, I have created an 
> example project which only connects to this hidden server basing on Apache 
> HttpClient libraries:
>  * org.apache.httpcomponents:httpcore:4.4.11
>  * org.apache.httpcomponents:httpclient:4.5.6
> The code looks like:
> {code:java}
> public static void main(String ...args) throws Exception {
>       System.setProperty("https.proxyHost", "<proxy_url>");
>       System.setProperty("https.proxyPort", "<proxy_port>");
>       System.setProperty("socksProxyHost", "<proxy_url>");
>       System.setProperty("socksProxyPort", "<proxy_port>");
>       URI uri = new URI("https://<hidden_server_url>");
>       try (CloseableHttpClient build = HttpClientBuilder.create()
>                       .useSystemProperties()
>                       .build()) {
>               final HttpUriRequest uriRequest = RequestBuilder.get()
>                               .setUri(uri)
>                               .build();
>               try (CloseableHttpResponse response = 
> build.execute(uriRequest)) {
>                       final StatusLine statusLine = response.getStatusLine();
>                       System.out.println(statusLine.toString());
>               }
>       }
> }
> {code}
> Unfortunately, as squid does not support SOCKS protocol, opening socket and 
> waiting for response hangs the program. I was thinking that maybe I'm basing 
> on invalid server configuration however when using below code everything 
> works fine for same system properties:
> {code:java}
> public static void main(String ...args) throws Exception {
>       System.setProperty("https.proxyHost", "<proxy_url>");
>       System.setProperty("https.proxyPort", "<proxy_port>");
>       System.setProperty("socksProxyHost", "<proxy_url>");
>       System.setProperty("socksProxyPort", "<proxy_port>");
>       URI uri = new URI("https://<hidden_server_url>");
>       try (InputStream stream = uri.toURL().openStream()){
>               String s = IOUtils.toString(stream, "UTF-8");
>               System.out.println(s != null);
>       } catch (IOException e) {
>               e.printStackTrace();
>       }
> }
> {code}
> So java itself handles it correctly. What is more if I simply remove the 
> socksProxyHost and socksProxyPort settings, then Apache HttpClient connects 
> correctly to the hidden server. I don't think that having both HTTPS proxy 
> configuration and SOCKS is incorrect as according to Oracle documentation:
> [https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html]
> {code:java}
> "Now, what happens when both a SOCKS proxy and a HTTP proxy are defined? Well 
> the rule is that settings for higher level protocols, like HTTP or FTP, take 
> precedence over SOCKS settings. So, in that particular case, when 
> establishing a HTTP connection, the SOCKS proxy settings will be ignored and 
> the HTTP proxy will be contacted. Let's look at an example:"
> {code}
> As in Apache HttpClient I'm using system properties (useSystemProperties) I 
> would expect that it is handled the same as Oracle does (the SOCK proxy 
> should be ignored). I also checked it for simple HTTP proxy (http.proxyHost, 
> http.proxyPort) and it acts the same (fails).
> Could you please help me with this issue?
> Best regards,
>  Mikolaj Broniszewski



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to