Using HttpProxy to connect to a host with preemtive authentication

前端 未结 1 1891
没有蜡笔的小新
没有蜡笔的小新 2020-12-18 15:40

I am using HttpClient to connect to a host which requires BasicAUTH. But the proxy doesn\'t require any authentication. I have set it up as follows:

private          


        
相关标签:
1条回答
  • 2020-12-18 16:31

    Here's an example from the Apache site for a proxy w/o credentials:

    http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientExecuteProxy.java

    (From http://hc.apache.org/httpcomponents-client-ga/examples.html)

    You are getting the error because you are passing in a username/password and don't need to.

    The WARN messages are coming from the logger (http://hc.apache.org/httpcomponents-client-ga/logging.html) - depending on how you have your logger set up you could just ignore that.

    Having spent WAY too much time dealing with trying to make a Java application deal with proxy servers, I can tell you that using a tool such as Proxifier ( http://www.proxifier.com/ for Mac OS X and Windows) or CNTLM ( http://cntlm.sourceforge.net/) was much easier, more flexible, easier to debug, and kept the code clean.

    0 讨论(0)
提交回复
热议问题