You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Lalit Sahoo <la...@sonata-software.com> on 2007/02/14 16:30:46 UTC
HttpClient class
Hi All,
Can anybody help me?
Is it necessary to use HttpClient class?
If I will use following approach what will be the disadvantage?
1. Create a connection manager
MultiThreadedHttpConnectionManager connManager = new MultiThreadedHttpConnectionManager ();
2. Create a host configuration
HostConfiguration hostConfig = new HostConfiguration ();
3. Set the host and port for host configuration
hostConfig.set (hostName, portNumber)
4. Create an HttpState instance
UsernamePasswordCredentials userCredentials = new UsernamePasswordCredentials (userName, password);
AuthScope authScope = new AuthScope (hostName, portNumber, realm, authenticationScheme);
HttpState httpState = new HttpState ();
httpState.setCredentials (authScope, userCredentials);
5. Get an http connection with timeout:
HttpConnection httpConnection = connManager.getConnectionWithTimeout (hostconfig, 1000);
6. Create an instance of get method:
String uri = "http://172.24.19.79:7001/SimpleWebSimulator/SOAPAgent";
GetMethod getMethod = new GetMethod (uri);
7. To execute this method:
getMethod.execute (httpState, httpConnection);
Regards,
Lalit
Re: HttpClient class
Posted by Oleg Kalnichevski <ol...@apache.org>.
Lalit Sahoo wrote:
> Hi Oleg,
>
> Could you please explain in little detail how HttpClient is related to SSL tunneling,redirect and authentication?
>
>
HttpClient uses a package private class called HttpMethodDirector to
take care of the SSL tunneling, redirect handling and authentication. If
you do not use HttpClient to execute requests you lose all that
functionality. I hope this is detailed enough
Oleg
>
> Regards,
> Lalit
>
> ________________________________
>
> From: Oleg Kalnichevski [mailto:olegk@apache.org]
> Sent: Wed 2/14/2007 9:11 PM
> To: HttpClient User Discussion
> Subject: Re: HttpClient class
>
>
>
> On Wed, 2007-02-14 at 21:00 +0530, Lalit Sahoo wrote:
>
>> Hi All,
>>
>> Can anybody help me?
>>
>> Is it necessary to use HttpClient class?
>>
>>
>
> No, it is not. The SSL tunneling, request recovery, redirects and
> authentication will not be handled automatically. That's all.
>
>
>
>> If I will use following approach what will be the disadvantage?
>>
>
> It depends on what you want to achieve
>
> Oleg
>
>
>
>> 1. Create a connection manager
>>
>>
>>
>> MultiThreadedHttpConnectionManager connManager = new MultiThreadedHttpConnectionManager ();
>>
>>
>>
>> 2. Create a host configuration
>>
>>
>>
>> HostConfiguration hostConfig = new HostConfiguration ();
>>
>>
>>
>> 3. Set the host and port for host configuration
>>
>>
>>
>> hostConfig.set (hostName, portNumber)
>>
>>
>>
>> 4. Create an HttpState instance
>>
>>
>>
>> UsernamePasswordCredentials userCredentials = new UsernamePasswordCredentials (userName, password);
>>
>> AuthScope authScope = new AuthScope (hostName, portNumber, realm, authenticationScheme);
>>
>> HttpState httpState = new HttpState ();
>>
>> httpState.setCredentials (authScope, userCredentials);
>>
>>
>>
>> 5. Get an http connection with timeout:
>>
>>
>>
>> HttpConnection httpConnection = connManager.getConnectionWithTimeout (hostconfig, 1000);
>>
>>
>>
>> 6. Create an instance of get method:
>>
>>
>>
>>
>>
>> String uri = "http://172.24.19.79:7001/SimpleWebSimulator/SOAPAgent";
>>
>> GetMethod getMethod = new GetMethod (uri);
>>
>>
>>
>> 7. To execute this method:
>>
>>
>>
>> getMethod.execute (httpState, httpConnection);
>>
>>
>>
>> Regards,
>>
>> Lalit
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
RE: HttpClient class
Posted by Lalit Sahoo <la...@sonata-software.com>.
Hi Oleg,
Could you please explain in little detail how HttpClient is related to SSL tunneling,redirect and authentication?
Regards,
Lalit
________________________________
From: Oleg Kalnichevski [mailto:olegk@apache.org]
Sent: Wed 2/14/2007 9:11 PM
To: HttpClient User Discussion
Subject: Re: HttpClient class
On Wed, 2007-02-14 at 21:00 +0530, Lalit Sahoo wrote:
> Hi All,
>
> Can anybody help me?
>
> Is it necessary to use HttpClient class?
>
No, it is not. The SSL tunneling, request recovery, redirects and
authentication will not be handled automatically. That's all.
> If I will use following approach what will be the disadvantage?
It depends on what you want to achieve
Oleg
>
>
> 1. Create a connection manager
>
>
>
> MultiThreadedHttpConnectionManager connManager = new MultiThreadedHttpConnectionManager ();
>
>
>
> 2. Create a host configuration
>
>
>
> HostConfiguration hostConfig = new HostConfiguration ();
>
>
>
> 3. Set the host and port for host configuration
>
>
>
> hostConfig.set (hostName, portNumber)
>
>
>
> 4. Create an HttpState instance
>
>
>
> UsernamePasswordCredentials userCredentials = new UsernamePasswordCredentials (userName, password);
>
> AuthScope authScope = new AuthScope (hostName, portNumber, realm, authenticationScheme);
>
> HttpState httpState = new HttpState ();
>
> httpState.setCredentials (authScope, userCredentials);
>
>
>
> 5. Get an http connection with timeout:
>
>
>
> HttpConnection httpConnection = connManager.getConnectionWithTimeout (hostconfig, 1000);
>
>
>
> 6. Create an instance of get method:
>
>
>
>
>
> String uri = "http://172.24.19.79:7001/SimpleWebSimulator/SOAPAgent";
>
> GetMethod getMethod = new GetMethod (uri);
>
>
>
> 7. To execute this method:
>
>
>
> getMethod.execute (httpState, httpConnection);
>
>
>
> Regards,
>
> Lalit
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: HttpClient class
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2007-02-14 at 21:00 +0530, Lalit Sahoo wrote:
> Hi All,
>
> Can anybody help me?
>
> Is it necessary to use HttpClient class?
>
No, it is not. The SSL tunneling, request recovery, redirects and
authentication will not be handled automatically. That's all.
> If I will use following approach what will be the disadvantage?
It depends on what you want to achieve
Oleg
>
>
> 1. Create a connection manager
>
>
>
> MultiThreadedHttpConnectionManager connManager = new MultiThreadedHttpConnectionManager ();
>
>
>
> 2. Create a host configuration
>
>
>
> HostConfiguration hostConfig = new HostConfiguration ();
>
>
>
> 3. Set the host and port for host configuration
>
>
>
> hostConfig.set (hostName, portNumber)
>
>
>
> 4. Create an HttpState instance
>
>
>
> UsernamePasswordCredentials userCredentials = new UsernamePasswordCredentials (userName, password);
>
> AuthScope authScope = new AuthScope (hostName, portNumber, realm, authenticationScheme);
>
> HttpState httpState = new HttpState ();
>
> httpState.setCredentials (authScope, userCredentials);
>
>
>
> 5. Get an http connection with timeout:
>
>
>
> HttpConnection httpConnection = connManager.getConnectionWithTimeout (hostconfig, 1000);
>
>
>
> 6. Create an instance of get method:
>
>
>
>
>
> String uri = "http://172.24.19.79:7001/SimpleWebSimulator/SOAPAgent";
>
> GetMethod getMethod = new GetMethod (uri);
>
>
>
> 7. To execute this method:
>
>
>
> getMethod.execute (httpState, httpConnection);
>
>
>
> Regards,
>
> Lalit
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org