Ernst,

You might check out the troubleshooting guide. See about turning on wire logging, for example. Then let us know what you find in the log.

The server can, of course, decide that it wants to "expire" your cookies. The server doesn't need to return them with each response. Cookies can be qualified by time, path and server, so perhaps your second request is for a different "context" as far as the cookie state is concerned? I note that the output you provide below does not print out the details of the cookies found in the original request, and that the two requests are on different paths.

A shorter sample of the problem would undoubtedly help out, as it would let us try exactly the same code you're trying.

-Eric.

Ernst de Haan wrote:

But that is the constructor which is called only once. So my code is correct, right? If not, please elaborate on what I should do differently.

Ernst

On maandag 6 oktober 2003 11:59, Kalnichevski, Oleg wrote:


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_logi
n=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&sub
mit=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]



Reply via email to