You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by JavierL <xl...@gmail.com> on 2008/09/23 15:45:34 UTC

Proxy without authentication


Hi

I'm doing an application that wants to connect to an external server with
httpclient. My problem is that I've a proxy between my computer and the
server.

I've the proxy ip and port and nothing more. In fact, my Firefox browser
just use this information to connect outside.

In my application I did:

-----------

String url = "http://www.yahoo.com";

 try {
            HostConfiguration config = new HostConfiguration();
            config.setProxyHost(new ProxyHost("172.26.18.147",8080));
            config.setHost(url);
            log.info("....host config done !");

            HttpClient httpclient = new HttpClient();
            httpclient.setHostConfiguration(config);
            httpclient.setState(new HttpState());
            log.info("....httpclient config done !");

            httpget = new GetMethod(url);
            log.info("....method done !");
                        
            httpclient.executeMethod(httpget);
            
            log.info("...status line: " + httpget.getStatusLine());
            
            in = httpget.getResponseBodyAsStream();
        } catch (Exception e) {
            log.error(e.getMessage());
        } finally {            
            httpget.releaseConnection();
        }

-----------

and when I run the application I receive the message:

156  INFO  YahooRetriever  - ....method done !
578  INFO  AuthChallengeProcessor  - ntlm authentication scheme selected
578  INFO  HttpMethodDirector  - No credentials available for NTLM <any
realm>@1
72.26.18.147:8080
578  INFO  YahooRetriever  - ...status line: HTTP/1.1 407 Proxy
Authentication R
equired
578  INFO  YahooParser  - Creating XML Reader

Am I wrong ? How can I do to pass through the proxy ?


Thanks in advance

J

-- 
View this message in context: http://www.nabble.com/Proxy-without-authentication-tp19628039p19628039.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Proxy without authentication

Posted by James Carman <ja...@carmanconsulting.com>.
System.setProperty() or on the command line:

java -Dhttp.proxyHost=myproxy.mycompany.com -Dhttp.proxyPort=8080


On Tue, Sep 23, 2008 at 10:02 AM, JavierL <xl...@gmail.com> wrote:
>
> Hi
>
> Where/How should I set them ?
>
>
> J
>
>
> jwcarman wrote:
>>
>> Have you tried setting the system properties "http.proxyHost" and
>> "http.proxyPort"?
>>
>> On Tue, Sep 23, 2008 at 9:45 AM, JavierL <xl...@gmail.com> wrote:
>>>
>>>
>>> Hi
>>>
>>> I'm doing an application that wants to connect to an external server with
>>> httpclient. My problem is that I've a proxy between my computer and the
>>> server.
>>>
>>> I've the proxy ip and port and nothing more. In fact, my Firefox browser
>>> just use this information to connect outside.
>>>
>>> In my application I did:
>>>
>>> -----------
>>>
>>> String url = "http://www.yahoo.com";
>>>
>>>  try {
>>>            HostConfiguration config = new HostConfiguration();
>>>            config.setProxyHost(new ProxyHost("172.26.18.147",8080));
>>>            config.setHost(url);
>>>            log.info("....host config done !");
>>>
>>>            HttpClient httpclient = new HttpClient();
>>>            httpclient.setHostConfiguration(config);
>>>            httpclient.setState(new HttpState());
>>>            log.info("....httpclient config done !");
>>>
>>>            httpget = new GetMethod(url);
>>>            log.info("....method done !");
>>>
>>>            httpclient.executeMethod(httpget);
>>>
>>>            log.info("...status line: " + httpget.getStatusLine());
>>>
>>>            in = httpget.getResponseBodyAsStream();
>>>        } catch (Exception e) {
>>>            log.error(e.getMessage());
>>>        } finally {
>>>            httpget.releaseConnection();
>>>        }
>>>
>>> -----------
>>>
>>> and when I run the application I receive the message:
>>>
>>> 156  INFO  YahooRetriever  - ....method done !
>>> 578  INFO  AuthChallengeProcessor  - ntlm authentication scheme selected
>>> 578  INFO  HttpMethodDirector  - No credentials available for NTLM <any
>>> realm>@1
>>> 72.26.18.147:8080
>>> 578  INFO  YahooRetriever  - ...status line: HTTP/1.1 407 Proxy
>>> Authentication R
>>> equired
>>> 578  INFO  YahooParser  - Creating XML Reader
>>>
>>> Am I wrong ? How can I do to pass through the proxy ?
>>>
>>>
>>> Thanks in advance
>>>
>>> J
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Proxy-without-authentication-tp19628039p19628039.html
>>> Sent from the Commons - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Proxy-without-authentication-tp19628039p19628407.html
> Sent from the Commons - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Proxy without authentication

Posted by JavierL <xl...@gmail.com>.

I found the solution, thanks..

J


JavierL wrote:
> 
> Hi
> 
> Where/How should I set them ?
> 
> 
> J
> 
> 
> jwcarman wrote:
>> 
>> Have you tried setting the system properties "http.proxyHost" and
>> "http.proxyPort"?
>> 
>> On Tue, Sep 23, 2008 at 9:45 AM, JavierL <xl...@gmail.com> wrote:
>>>
>>>
>>> Hi
>>>
>>> I'm doing an application that wants to connect to an external server
>>> with
>>> httpclient. My problem is that I've a proxy between my computer and the
>>> server.
>>>
>>> I've the proxy ip and port and nothing more. In fact, my Firefox browser
>>> just use this information to connect outside.
>>>
>>> In my application I did:
>>>
>>> -----------
>>>
>>> String url = "http://www.yahoo.com";
>>>
>>>  try {
>>>            HostConfiguration config = new HostConfiguration();
>>>            config.setProxyHost(new ProxyHost("172.26.18.147",8080));
>>>            config.setHost(url);
>>>            log.info("....host config done !");
>>>
>>>            HttpClient httpclient = new HttpClient();
>>>            httpclient.setHostConfiguration(config);
>>>            httpclient.setState(new HttpState());
>>>            log.info("....httpclient config done !");
>>>
>>>            httpget = new GetMethod(url);
>>>            log.info("....method done !");
>>>
>>>            httpclient.executeMethod(httpget);
>>>
>>>            log.info("...status line: " + httpget.getStatusLine());
>>>
>>>            in = httpget.getResponseBodyAsStream();
>>>        } catch (Exception e) {
>>>            log.error(e.getMessage());
>>>        } finally {
>>>            httpget.releaseConnection();
>>>        }
>>>
>>> -----------
>>>
>>> and when I run the application I receive the message:
>>>
>>> 156  INFO  YahooRetriever  - ....method done !
>>> 578  INFO  AuthChallengeProcessor  - ntlm authentication scheme selected
>>> 578  INFO  HttpMethodDirector  - No credentials available for NTLM <any
>>> realm>@1
>>> 72.26.18.147:8080
>>> 578  INFO  YahooRetriever  - ...status line: HTTP/1.1 407 Proxy
>>> Authentication R
>>> equired
>>> 578  INFO  YahooParser  - Creating XML Reader
>>>
>>> Am I wrong ? How can I do to pass through the proxy ?
>>>
>>>
>>> Thanks in advance
>>>
>>> J
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Proxy-without-authentication-tp19628039p19628039.html
>>> Sent from the Commons - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxy-without-authentication-tp19628039p19628455.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Proxy without authentication

Posted by JavierL <xl...@gmail.com>.
Hi

Where/How should I set them ?


J


jwcarman wrote:
> 
> Have you tried setting the system properties "http.proxyHost" and
> "http.proxyPort"?
> 
> On Tue, Sep 23, 2008 at 9:45 AM, JavierL <xl...@gmail.com> wrote:
>>
>>
>> Hi
>>
>> I'm doing an application that wants to connect to an external server with
>> httpclient. My problem is that I've a proxy between my computer and the
>> server.
>>
>> I've the proxy ip and port and nothing more. In fact, my Firefox browser
>> just use this information to connect outside.
>>
>> In my application I did:
>>
>> -----------
>>
>> String url = "http://www.yahoo.com";
>>
>>  try {
>>            HostConfiguration config = new HostConfiguration();
>>            config.setProxyHost(new ProxyHost("172.26.18.147",8080));
>>            config.setHost(url);
>>            log.info("....host config done !");
>>
>>            HttpClient httpclient = new HttpClient();
>>            httpclient.setHostConfiguration(config);
>>            httpclient.setState(new HttpState());
>>            log.info("....httpclient config done !");
>>
>>            httpget = new GetMethod(url);
>>            log.info("....method done !");
>>
>>            httpclient.executeMethod(httpget);
>>
>>            log.info("...status line: " + httpget.getStatusLine());
>>
>>            in = httpget.getResponseBodyAsStream();
>>        } catch (Exception e) {
>>            log.error(e.getMessage());
>>        } finally {
>>            httpget.releaseConnection();
>>        }
>>
>> -----------
>>
>> and when I run the application I receive the message:
>>
>> 156  INFO  YahooRetriever  - ....method done !
>> 578  INFO  AuthChallengeProcessor  - ntlm authentication scheme selected
>> 578  INFO  HttpMethodDirector  - No credentials available for NTLM <any
>> realm>@1
>> 72.26.18.147:8080
>> 578  INFO  YahooRetriever  - ...status line: HTTP/1.1 407 Proxy
>> Authentication R
>> equired
>> 578  INFO  YahooParser  - Creating XML Reader
>>
>> Am I wrong ? How can I do to pass through the proxy ?
>>
>>
>> Thanks in advance
>>
>> J
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Proxy-without-authentication-tp19628039p19628039.html
>> Sent from the Commons - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxy-without-authentication-tp19628039p19628407.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Proxy without authentication

Posted by James Carman <ja...@carmanconsulting.com>.
Have you tried setting the system properties "http.proxyHost" and
"http.proxyPort"?

On Tue, Sep 23, 2008 at 9:45 AM, JavierL <xl...@gmail.com> wrote:
>
>
> Hi
>
> I'm doing an application that wants to connect to an external server with
> httpclient. My problem is that I've a proxy between my computer and the
> server.
>
> I've the proxy ip and port and nothing more. In fact, my Firefox browser
> just use this information to connect outside.
>
> In my application I did:
>
> -----------
>
> String url = "http://www.yahoo.com";
>
>  try {
>            HostConfiguration config = new HostConfiguration();
>            config.setProxyHost(new ProxyHost("172.26.18.147",8080));
>            config.setHost(url);
>            log.info("....host config done !");
>
>            HttpClient httpclient = new HttpClient();
>            httpclient.setHostConfiguration(config);
>            httpclient.setState(new HttpState());
>            log.info("....httpclient config done !");
>
>            httpget = new GetMethod(url);
>            log.info("....method done !");
>
>            httpclient.executeMethod(httpget);
>
>            log.info("...status line: " + httpget.getStatusLine());
>
>            in = httpget.getResponseBodyAsStream();
>        } catch (Exception e) {
>            log.error(e.getMessage());
>        } finally {
>            httpget.releaseConnection();
>        }
>
> -----------
>
> and when I run the application I receive the message:
>
> 156  INFO  YahooRetriever  - ....method done !
> 578  INFO  AuthChallengeProcessor  - ntlm authentication scheme selected
> 578  INFO  HttpMethodDirector  - No credentials available for NTLM <any
> realm>@1
> 72.26.18.147:8080
> 578  INFO  YahooRetriever  - ...status line: HTTP/1.1 407 Proxy
> Authentication R
> equired
> 578  INFO  YahooParser  - Creating XML Reader
>
> Am I wrong ? How can I do to pass through the proxy ?
>
>
> Thanks in advance
>
> J
>
> --
> View this message in context: http://www.nabble.com/Proxy-without-authentication-tp19628039p19628039.html
> Sent from the Commons - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org