hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <oleg.kalnichev...@bearingpoint.com>
Subject Re: RE : How to use two distinct HttpClients on the same web site
Date Thu, 26 Aug 2004 11:42:26 GMT

On Thu, 2004-08-26 at 11:28, Fabien BALAGEAS wrote:
> Thank you Oleg,
>
> I was not able to keep the "hostconfiguration" parameter to null in
>
> 	httpclient.executeMethod(null, httpget1, httpstate1);
>
> I had to set it to httpClient.getHostConfiguration()...
>
> In fact, i want to access the same logical web application "http://www.whatever.com/app"
on one physical server, but from two different logical users.
>
> When i execute your sample, httpget1 and httpget2 has the same session ID if i connect
to the same web app ("http://www.whatever.com/app"). The cookie automatically sent by HttpClient
on httpget2 is the same as the one received from httpget1.
> So the server see my two connections as if they were from the same user...
>

Fabien,

I do not why this is happening. I would expect a well-behaved web server
to redirect the request to the login page whenever the session ID cookie
is not present. What web server / app server are you using?

A debug/wire log of the HTTP session might help pinpoint the problem.
Please refer to the HttpClient logging guide for details on how to
activate the wire/debug logging

http://jakarta.apache.org/commons/httpclient/logging.html

Please do take time to obfuscate security sensitive information in the
log, such as authentication credentials, prior to posting it to the
list 

Oleg


> How to handle that??? I mean: is there a way to tell to HttpClient to maintain distinct
cookies on distinct state?
>
> Fabien
>
>
> -----Message d'origine-----
> De : Oleg Kalnichevski [mailto:oleg.kalnichevski@bearingpoint.com]
> Envoyé : jeudi 26 août 2004 10:50
> À : Commons HttpClient Project
> Objet : Re: How to use two distinct HttpClients on the same web site
>
>
>
> Fabien,
>
> If all you need is to maintain a distinct conversational state per logical web application
hosted on the same physical platform, you should have just only one HttpClient instance and
then keep different HttpState instances per web application. It does take a bit of HttpState
juggling, but the benefit of such setup will be a better overall performance, as HttpClient
would be able to reuse physical connections to the host.
>
> =================================================================
> HttpClient httpclient = new HttpClient();
>
> HttpState httpstate1 = new HttpState();
> GetMethod httpget1 = new GetMethod("http://www.whatever.com/app1");
> try {
> 	httpclient.executeMethod(null, httpget1, httpstate1);
> 	System.out.println(httpget1.getStatusLine());
> 	System.out.println(httpget1.getResponseBodyAsString());
> 	httpstate1.getCookies();
> } finally {
> 	httpget1.releaseConnection();
> }
>
> HttpState httpstate2 = new HttpState();
> GetMethod httpget2 = new GetMethod("http://www.whatever.com/app2");
> try {
> 	httpclient.executeMethod(null, httpget2, httpstate2);
> 	System.out.println(httpget2.getStatusLine());
> 	System.out.println(httpget2.getResponseBodyAsString());
> 	httpstate2.getCookies();
> } finally {
> 	httpget2.releaseConnection();
> }
> 
> Hope this helps
>
> Oleg
>
> On Thu, 2004-08-26 at 08:46, Fabien BALAGEAS wrote:
> > Hi,
> > 
> > I am using HttpClient 2.0.1.
> > 
> > I would like to have two HttpClient connections to the same web site
> > in my application, but from two "distinct" HttpClient (i.e. each
> > connection should handle its self cookies).
> > 
> > How can i realize this task ?
> > 
> > Up to now, i only managed to have two connections to the web site, but
> > with the same cookies sent, so the web site see my two connections as
> > if they were one.
> > 
> > Thanks in advance for your help,
> > Fabien
> > 
>
> ***************************************************************************************************
> The information in this email is confidential and may be legally privileged.  Access
to this email by anyone other than the intended addressee is unauthorized.  If you are not
the intended recipient of this message, any review, disclosure, copying, distribution, retention,
or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful.
 If you are not the intended recipient, please reply to or forward a copy of this message
to the sender and delete the message, any attachments, and any copies thereof from your system.
> ***************************************************************************************************
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org

***************************************************************************************************
The information in this email is confidential and may be legally privileged.  Access to this
email by anyone other than the intended addressee is unauthorized.  If you are not the intended
recipient of this message, any review, disclosure, copying, distribution, retention, or any
action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. 
If you are not the intended recipient, please reply to or forward a copy of this message to
the sender and delete the message, any attachments, and any copies thereof from your system.
***************************************************************************************************

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


Mime
View raw message