title: Proxy authentication problem with HttpClient
body: <p>I have a thick client application which connects to a server on the internet for file transmission and upload. </p>
  
  <p>However, the access to the internet is via proxy. I am using HttpClient on the thick client and Apache Commons file upload on the server side. </p>
  
  <p>I am setting the proxy on the HttpClient as below: </p>
  
  <pre><code>HttpClient client = new  HttpClient(); 
  HostConfiguration config = client.getHostConfiguration(); 
  config.setProxy(PROXY_HOST, PROXY_PORT); 
  
  PostMethod filePost = new PostMethod(servletPath); 
  int status = client.executeMethod(config , filePost); 
  </code></pre>
  
  <p>However, instead of hardcoding values for PROXY_HOST, PROXY_PORT above, I am using HttpUrlConnection to get the proxy information and set into these values. This works fine. </p>
  
  <p>If I dont set the proxy settings like this, HttpClient is ignoring my proxy settings and not detecting them automatically and as a result my application is not able to connect to the server on the internet. </p>
  
  <p>Now when I connect to the server using HttpClient, the request goes via proxy but fails as it expects user authentication credentials for the proxy information provided. I am not able to figure out a way how to make this work as I expected a popup for the user to enter user id and password, once connected to the proxy instead of request failing altogether. </p>
  
  <p>Can somebody suggest how to make HttpClient work with proxy without hardcoding the PROXY_HOST, PROXY_PORT values. </p>
  
  <p>Also, this application will be launched from thick client for different users. So the proxy information should be automatically detected from browser settings (which is what the HttpUrlConnection is doing for me). </p>
  
  <p>Can somebody please suggest a solution for this scenario? </p>