On Tue, 2018-07-24 at 20:50 +0530, Sreyan Chakravarty wrote: > I am on a Windows machine at work and am using HttpClient to make a > request > via a web proxy. But the problem is that I keep 407 Authentication > required > message. > > But if I do the same thing via the RestTemplate of Spring, which uses > the > vanilla java.net.URLConnection class, with supplying just the proxy > address > and port, it works fine. *It doesn't even need the user name and > password > for authentication. * > > Why does this work? Why does HttpClient fail? > > Doing some digging into the source I made out that HttpClient first > opens a > socket to the required address and then reads and writes from that > socket. > AFAIK, java.net.URLConnection does not do that. > > So my question is what does java.net.URLConnection do differently? > What is > the difference between opening a socket. > > Also how do I make HttpClient behave like java.net.URLConnection so > that I > can avoid the error. > > Clearly java.net.URLConnection is doing something right. >
Right or wrong, it uses Windows platform specific authentication code. HttpClient supports native Windows authentication when running on Windows family of OSes http://hc.apache.org/httpcomponents-client-4.5.x/httpclient-win/apidocs /index.html Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org