________________________________

From: Fadi M. Maali 
Sent: Tuesday, January 01, 2008 9:27 AM
To: '[email protected]'
Subject: Proxy Authentication Required

 

Hi All,

 

I was able to connect to a site using java.net.URL after setting the
proxy using System.setProperty() . But I am getting a "HTTP/1.1 407
Proxy Authentication Required" response when I am trying to use
HttpClient. Below is a snapshot. 

Thanks in advance!

 

** this code works well**

System.setProperty("http.proxyHost", "myproxy");

            System.setProperty("http.proxyPort","80");

            

            URL url = new URL("http://somehost";);

            BufferedReader in = new BufferedReader(new
InputStreamReader(url.openStream()));

            

            String inputLine;

 

            while ((inputLine = in.readLine()) != null)

                System.out.println(inputLine);

 

 

**but this code returns 407"

HttpClient client = new HttpClient();

            HttpMethod method = new
GetMethod("http://www.somehost.com";);

            method.setFollowRedirects(true);

            String responseBody = null;

            

            try{

                  client.getHostConfiguration().setProxy("myproxy", 80);

            

                  client.executeMethod(method);

                  responseBody = method.getResponseBodyAsString();

                  System.out.println(responseBody);

            }catch(HttpException he){

                  System.out.println(he.getMessage());

                  he.printStackTrace();

            }catch(IOException ie){

                  ie.printStackTrace();

            }

IMPORTANT NOTICE: CONFIDENTIAL AND LEGAL PRIVILEGE

This electronic communication is intended by the sender only for the access and 
use by the addressee and may contain legally privileged and confidential 
information. If you are not the addressee, you are notified that any 
transmission, disclosure, use, access to, storage or photocopying of this 
e-mail and any attachments is strictly prohibited. The legal privilege and 
confidentiality attached to this e-mail and any attachments is not waived, lost 
or destroyed by reason of a mistaken delivery to you. If you have received this 
e-mail and any attachments in error please immediately delete it and all copies 
from your system and notify the sender by e-mail. Nothing in this communication 
is intended to operate as an electronic signature under any applicable law...

Reply via email to