Ernst,
Cookies are not deleted by HttpClient unless they are expired. I am pretty sure about
it
In your particular case there's a bug in the following piece of code
public AddReleaseTask() {
HttpState httpState = new HttpState();
httpState.setCookiePolicy(CookiePolicy.COMPATIBILITY);
_httpClient = new HttpClient();
_httpClient.setConnectionTimeout(7000); // 7 seconds
_httpClient.setTimeout(5000); // 5 seconds
_httpClient.setState(httpState);
}
There's a new instance of HttpState created every time the method is executed. As a
result the old one gets garbage collected along with all the cookies it contains. Just
keep the original HttpState instance to stop your cookies from disappearing
HTH
Oleg
-----Original Message-----
From: Ernst de Haan [mailto:[EMAIL PROTECTED]
Sent: Monday, October 06, 2003 11:44
To: Commons HttpClient Project
Subject: Why are cookies deleted?
Hi,
Why are cookies deleted from the state registered with my HttpClient object?
I do a request (GetMethod) that returns 2 cookies. Then I do another request
(using another GetMethod) and with that I lose both cookies. Should I
recycle the original method or should I release the connection or should I
do something else?
I'm pretty sure the site does not delete the cookies self, although I'm not
100% sure. How can I determine this?
Source code:
http://people.freebsd.org/~znerd/AddReleaseTask.java
Output log:
[sfaddrelease] Using keystore file "src/certificates/sourceforge.net.cert".
[sfaddrelease] Logging in to SourceForge site as "znerd".
[sfaddrelease] Executing request "https://sourceforge.net/account/
login.php?return_to=&form_loginname=znerd&form_pw=Secret1&persistent_login=1&login=Login
+With+SSL".
[sfaddrelease] Received 2 cookies.
[sfaddrelease] Received cookie: session_ser=4mwuT3NmTwAcip%
2BNYbMb3kufdYs1ecnResrJ4qvW64J3DO1UjOB9najRyGZHsvly%2F7%
2FApd7J6HNaZzO47tBkuaT0juKf20pqVZSSAZh2eho%
3D-9b1d4e8f9591972e74e19fee00ea1f7a
[sfaddrelease] Received cookie: persist_session=Vd18PV2KlUs%3D
[sfaddrelease] Logged in to SourceForge site as "znerd".
[sfaddrelease] Creating release "0.127-dev" for group 71598, package 71219.
[sfaddrelease] Current cookie count is 2
[sfaddrelease] Executing request "https://sourceforge.net/project/admin/
newrelease.php?group_id=71598&package_id=71219&release_name=0.127-dev&submit=Create
+This+Release".
[sfaddrelease] Received status line: HTTP/1.1 200 OK
[sfaddrelease] Current cookie count is 0
[sfaddrelease] Created release "0.127-dev" for group 71598, package 71219.
--
Ernst
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]