httpClient proxy support in apache commons 3.1

Posted by user1173339 on Stack Overflow See other posts from Stack Overflow or by user1173339
Published on 2012-11-02T16:03:53Z Indexed on 2012/11/02 17:02 UTC
Read the original article Hit count: 403

Filed under:
|
|
|

I am using apache commons 3.1 to implement httpClient with proxy support. I am trying to connect to a remote host through proxy. The proxy server is configured without any authentication, however the the remote host is configured with authentication. When I am passing the proxy parameters through properties file, it gives warning while execution:

WARN - Required proxy credentials not available for BASIC @xx.xx.xx.xx WARN - Preemptive authentication requested but no default proxy credentials availble

But the execution goes ahead.

On the other hand when I am passing the proxy parameters through the JVM arguments then the again the same warning is given and the execution is stopped.

Is there any specific reason for this behavior? Is there any difference in passing the proxy parameters through properties file and through JVM arg?

Here is the code:

if(System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null) {
            httpClient.getHostConfiguration().setProxy(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort")));
        }
        else if(AMXAdminTask.props.getProperty("http.proxyHost") != null && AMXAdminTask.props.getProperty("http.proxyPort") != null) {
            httpClient.getHostConfiguration().setProxy(Propfile.props.getProperty("http.proxyHost"), Integer.parseInt(Propfile.props.getProperty("http.proxyPort")));
        }

© Stack Overflow or respective owner

Related posts about java

Related posts about apache