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 ma...@interia.pl on 2004/12/15 01:19:51 UTC
Cookie problem
Hello,
I use HttpClient 2.0.2
I have a little problem with cookies.
I write a servlet, to work as a kind of proxy to a different http server.
So I take my HttpServletRequest, rewrite it's method, and header to
a HttpClient and execute that method.
After that, I take a response from method, rewrite header to HttpServletResponse and
rewrite also a body (binary). And everythink works fine but I have a little problem with cookies.
When a cookie came with header from HttpClient (Set-cookie), it is just rewritten to HttpServletResponse
and I can see in my browser then that cookie with proper value.
When I try to sent a cookie to HttpClient from HttpServletrequest:
I know that it can't be rewritten with header (I've found that in archive).
So I write:
String url = "http://www.my.address.org/"
HostConfiguration config = new HostConfiguration();
config.setHost(url, 80);
HttpClient client = new HttpClient();
HttpState state = client.getState();
Cookie myCookie = new Cookie(url, some_name, some_value);
state.addCookie(myCookie);
PostMethod method = new PostMethod(url); //I use post and get method
// add header, and parameters here
client.executeMethod(config, method, state);
and when I look at the things which where sent to the server i can see
that there are no cookie header at all. Rest of the package looks ok (there is rest of the
headers and protocol and everything as it should be).
The name and value i take from a cookie which
where sent to me by HttpServletRequest, and I have checked them, there are ok.
What is wrong? What is the correct way to add a cookie to request?
Marcin Piatek
----------------------------------------------------------------------
Startuj z INTERIA.PL!!! >>> http://link.interia.pl/f1837
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Cookie problem
Posted by Marcin Piątek <ma...@interia.pl>.
I will do that!
Thanks vary much you all, for your help and your soft.
Oleg Kalnichevski napisał(a):
>Yes, it is. There's a (fairly ugly) way to work the problem around with
>HttpClient 2.0.x, however we strongly urge you to consider upgrading to
>HttpClient 3.0 instead. HttpClient 3.0 should go RC (release candidate)
>sometime in January with a final release following shortly
>
>Oleg
>
>
>On Thu, Dec 16, 2004 at 09:47:26AM +0100, Marcin Pi??tek wrote:
>
>
>>Thank you very much.
>>
>>Is that patch included to HttpClient 3.0?
>>
>>Roland Weber napisa??(a):
>>
>>
>>
>>>Hello Marcin,
>>>
>>>somewhere down the road, it has been made possible
>>>to set the cookie header manually:
>>>http://issues.apache.org/bugzilla/show_bug.cgi?id=24081
>>>
>>>I think that is just what you need.
>>>
>>>cheers,
>>>Roland
>>>
>>>
>>>
>>>
>>>madey22@interia.pl
>>>15.12.2004 01:19
>>>Please respond to
>>>"HttpClient User Discussion"
>>>
>>>
>>>To
>>>httpclient-user@jakarta.apache.org
>>>cc
>>>
>>>Subject
>>>Cookie problem
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>Hello,
>>>I use HttpClient 2.0.2
>>>I have a little problem with cookies.
>>>I write a servlet, to work as a kind of proxy to a different http server.
>>>So I take my HttpServletRequest, rewrite it's method, and header to
>>>a HttpClient and execute that method.
>>>After that, I take a response from method, rewrite header to
>>>HttpServletResponse and
>>>rewrite also a body (binary). And everythink works fine but I have a
>>>little problem with cookies.
>>>When a cookie came with header from HttpClient (Set-cookie), it is just
>>>rewritten to HttpServletResponse
>>>and I can see in my browser then that cookie with proper value.
>>>When I try to sent a cookie to HttpClient from HttpServletrequest:
>>>I know that it can't be rewritten with header (I've found that in
>>>archive).
>>>So I write:
>>>
>>>String url = "http://www.my.address.org/"
>>>
>>>HostConfiguration config = new HostConfiguration();
>>>config.setHost(url, 80);
>>>HttpClient client = new HttpClient();
>>>HttpState state = client.getState();
>>>Cookie myCookie = new Cookie(url, some_name, some_value);
>>>state.addCookie(myCookie);
>>>
>>>PostMethod method = new PostMethod(url); //I use post and get method
>>>// add header, and parameters here
>>>
>>>client.executeMethod(config, method, state);
>>>
>>>and when I look at the things which where sent to the server i can see
>>>that there are no cookie header at all. Rest of the package looks ok
>>>(there is rest of the
>>>headers and protocol and everything as it should be).
>>>The name and value i take from a cookie which
>>>where sent to me by HttpServletRequest, and I have checked them, there are
>>>ok.
>>>What is wrong? What is the correct way to add a cookie to request?
>>>
>>>Marcin Piatek
>>>
>>>----------------------------------------------------------------------
>>>Startuj z INTERIA.PL!!! >>> http://link.interia.pl/f1837
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>--
>>-------------------------------------------------------------------------------
>>-- Free your code!!!
>>-------------------------------------------------------------------------------
>>
>>
>>----------------------------------------------------------------------
>>Dzwonisz za granice? >>> http://link.interia.pl/f183f
>>
>>
>>---------------------------------------------------------------------
>>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
>
>
>
>
>
--
-------------------------------------------------------------------------------
-- Free your code!!!
-------------------------------------------------------------------------------
----------------------------------------------------------------------
Dzwonisz za granice? >>> http://link.interia.pl/f183f
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Cookie problem
Posted by Oleg Kalnichevski <ol...@apache.org>.
Yes, it is. There's a (fairly ugly) way to work the problem around with
HttpClient 2.0.x, however we strongly urge you to consider upgrading to
HttpClient 3.0 instead. HttpClient 3.0 should go RC (release candidate)
sometime in January with a final release following shortly
Oleg
On Thu, Dec 16, 2004 at 09:47:26AM +0100, Marcin Pi??tek wrote:
> Thank you very much.
>
> Is that patch included to HttpClient 3.0?
>
> Roland Weber napisa??(a):
>
> >Hello Marcin,
> >
> >somewhere down the road, it has been made possible
> >to set the cookie header manually:
> >http://issues.apache.org/bugzilla/show_bug.cgi?id=24081
> >
> >I think that is just what you need.
> >
> >cheers,
> > Roland
> >
> >
> >
> >
> >madey22@interia.pl
> >15.12.2004 01:19
> >Please respond to
> >"HttpClient User Discussion"
> >
> >
> >To
> >httpclient-user@jakarta.apache.org
> >cc
> >
> >Subject
> >Cookie problem
> >
> >
> >
> >
> >
> >
> >
> >Hello,
> >I use HttpClient 2.0.2
> >I have a little problem with cookies.
> >I write a servlet, to work as a kind of proxy to a different http server.
> >So I take my HttpServletRequest, rewrite it's method, and header to
> >a HttpClient and execute that method.
> >After that, I take a response from method, rewrite header to
> >HttpServletResponse and
> >rewrite also a body (binary). And everythink works fine but I have a
> >little problem with cookies.
> >When a cookie came with header from HttpClient (Set-cookie), it is just
> >rewritten to HttpServletResponse
> >and I can see in my browser then that cookie with proper value.
> >When I try to sent a cookie to HttpClient from HttpServletrequest:
> >I know that it can't be rewritten with header (I've found that in
> >archive).
> >So I write:
> >
> >String url = "http://www.my.address.org/"
> >
> >HostConfiguration config = new HostConfiguration();
> >config.setHost(url, 80);
> >HttpClient client = new HttpClient();
> >HttpState state = client.getState();
> >Cookie myCookie = new Cookie(url, some_name, some_value);
> >state.addCookie(myCookie);
> >
> >PostMethod method = new PostMethod(url); //I use post and get method
> >// add header, and parameters here
> >
> >client.executeMethod(config, method, state);
> >
> >and when I look at the things which where sent to the server i can see
> >that there are no cookie header at all. Rest of the package looks ok
> >(there is rest of the
> >headers and protocol and everything as it should be).
> >The name and value i take from a cookie which
> >where sent to me by HttpServletRequest, and I have checked them, there are
> >ok.
> >What is wrong? What is the correct way to add a cookie to request?
> >
> >Marcin Piatek
> >
> >----------------------------------------------------------------------
> >Startuj z INTERIA.PL!!! >>> http://link.interia.pl/f1837
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
> >
> >
> >
> >
>
>
> --
> -------------------------------------------------------------------------------
> -- Free your code!!!
> -------------------------------------------------------------------------------
>
>
> ----------------------------------------------------------------------
> Dzwonisz za granice? >>> http://link.interia.pl/f183f
>
>
> ---------------------------------------------------------------------
> 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: Cookie problem
Posted by Roland Weber <RO...@de.ibm.com>.
Marcin Piątek <ma...@interia.pl> wrote on 16.12.2004 09:47:26:
> Thank you very much.
>
> Is that patch included to HttpClient 3.0?
>
Yes it is.
> Roland Weber napisał(a):
>
> >Hello Marcin,
> >
> >somewhere down the road, it has been made possible
> >to set the cookie header manually:
> >http://issues.apache.org/bugzilla/show_bug.cgi?id=24081
> >
> >I think that is just what you need.
> >
> >cheers,
> > Roland
> >
cheers,
Roland
Re: Cookie problem
Posted by Marcin Piątek <ma...@interia.pl>.
Thank you very much.
Is that patch included to HttpClient 3.0?
Roland Weber napisał(a):
>Hello Marcin,
>
>somewhere down the road, it has been made possible
>to set the cookie header manually:
>http://issues.apache.org/bugzilla/show_bug.cgi?id=24081
>
>I think that is just what you need.
>
>cheers,
> Roland
>
>
>
>
>madey22@interia.pl
>15.12.2004 01:19
>Please respond to
>"HttpClient User Discussion"
>
>
>To
>httpclient-user@jakarta.apache.org
>cc
>
>Subject
>Cookie problem
>
>
>
>
>
>
>
>Hello,
>I use HttpClient 2.0.2
>I have a little problem with cookies.
>I write a servlet, to work as a kind of proxy to a different http server.
>So I take my HttpServletRequest, rewrite it's method, and header to
>a HttpClient and execute that method.
>After that, I take a response from method, rewrite header to
>HttpServletResponse and
>rewrite also a body (binary). And everythink works fine but I have a
>little problem with cookies.
>When a cookie came with header from HttpClient (Set-cookie), it is just
>rewritten to HttpServletResponse
>and I can see in my browser then that cookie with proper value.
>When I try to sent a cookie to HttpClient from HttpServletrequest:
>I know that it can't be rewritten with header (I've found that in
>archive).
>So I write:
>
>String url = "http://www.my.address.org/"
>
>HostConfiguration config = new HostConfiguration();
>config.setHost(url, 80);
>HttpClient client = new HttpClient();
>HttpState state = client.getState();
>Cookie myCookie = new Cookie(url, some_name, some_value);
>state.addCookie(myCookie);
>
>PostMethod method = new PostMethod(url); //I use post and get method
>// add header, and parameters here
>
>client.executeMethod(config, method, state);
>
>and when I look at the things which where sent to the server i can see
>that there are no cookie header at all. Rest of the package looks ok
>(there is rest of the
>headers and protocol and everything as it should be).
>The name and value i take from a cookie which
>where sent to me by HttpServletRequest, and I have checked them, there are
>ok.
>What is wrong? What is the correct way to add a cookie to request?
>
>Marcin Piatek
>
>----------------------------------------------------------------------
>Startuj z INTERIA.PL!!! >>> http://link.interia.pl/f1837
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
>
>
>
--
-------------------------------------------------------------------------------
-- Free your code!!!
-------------------------------------------------------------------------------
----------------------------------------------------------------------
Dzwonisz za granice? >>> http://link.interia.pl/f183f
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Cookie problem
Posted by Roland Weber <RO...@de.ibm.com>.
Hello Marcin,
somewhere down the road, it has been made possible
to set the cookie header manually:
http://issues.apache.org/bugzilla/show_bug.cgi?id=24081
I think that is just what you need.
cheers,
Roland
madey22@interia.pl
15.12.2004 01:19
Please respond to
"HttpClient User Discussion"
To
httpclient-user@jakarta.apache.org
cc
Subject
Cookie problem
Hello,
I use HttpClient 2.0.2
I have a little problem with cookies.
I write a servlet, to work as a kind of proxy to a different http server.
So I take my HttpServletRequest, rewrite it's method, and header to
a HttpClient and execute that method.
After that, I take a response from method, rewrite header to
HttpServletResponse and
rewrite also a body (binary). And everythink works fine but I have a
little problem with cookies.
When a cookie came with header from HttpClient (Set-cookie), it is just
rewritten to HttpServletResponse
and I can see in my browser then that cookie with proper value.
When I try to sent a cookie to HttpClient from HttpServletrequest:
I know that it can't be rewritten with header (I've found that in
archive).
So I write:
String url = "http://www.my.address.org/"
HostConfiguration config = new HostConfiguration();
config.setHost(url, 80);
HttpClient client = new HttpClient();
HttpState state = client.getState();
Cookie myCookie = new Cookie(url, some_name, some_value);
state.addCookie(myCookie);
PostMethod method = new PostMethod(url); //I use post and get method
// add header, and parameters here
client.executeMethod(config, method, state);
and when I look at the things which where sent to the server i can see
that there are no cookie header at all. Rest of the package looks ok
(there is rest of the
headers and protocol and everything as it should be).
The name and value i take from a cookie which
where sent to me by HttpServletRequest, and I have checked them, there are
ok.
What is wrong? What is the correct way to add a cookie to request?
Marcin Piatek
----------------------------------------------------------------------
Startuj z INTERIA.PL!!! >>> http://link.interia.pl/f1837
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org