Hello,

I am using HtmlUnit to run testcases against my web application.  On the
login page I do a form post containing the login information.  ServletExec
generates
a "sesessionid" that is set as a cookie.  This obviously works on a browser
but using HttpClient for a client does not work.  I have examined the http
requests
and responses to get a better idea of what is happening.

The browser does the post:

POST /myaquent?APROC=Login HTTP/1.1


and sets the cookies:

> Set-Cookie: UserType=7
> Set-Cookie: UserName=dperez
> Set-Cookie: storeFilesInUBO=true
> Set-Cookie: sesessionid=gsr2kEn5BATC8oHBKhcLC6Kf4Eo; path=/


HttpClient does the post (I think...it doesn't explicitly say POST in the
Header)
and sets the cookies:

Set-Cookie: UserType=7
> Set-Cookie: UserName=dperez
> Set-Cookie: storeFilesInUBO=true
> Set-Cookie: sesessionid=0fWKNFTdZ4wanoGkODbXNNzSOXY; path=/
>
> Cookie accepted: "$Version=0; UserType=7"
> Cookie accepted: "$Version=0; UserName=dperez"
> Cookie accepted: "$Version=0; storeFilesInUBO=true"
> Cookie accepted: "$Version=0; sesessionid=0fWKNFTdZ4wanoGkODbXNNzSOXY;
> $Path=/"
>

The Cookie accepted lines add $Version=0 which I am not too sure why or
even what that means.

The interesting part is the next request I make for the main window of the
webapp.

The browser sends the same cookie values (THIS WORKS):

Cookie: UserType=7; UserName=dperez; storeFilesInUBO=true;
> sesessionid=gsr2kEn5BATC8oHBKhcLC6Kf4Eo


but HttpClient sends them differently (DOES NOT WORK):

> "Cookie: $Version=0; UserType=7
> "Cookie: $Version=0; UserName=dperez
> "Cookie: $Version=0; storeFilesInUBO=true
> "Cookie: $Version=0; sesessionid=0fWKNFTdZ4wanoGkODbXNNzSOXY; $Path=/


which results in the sessionId being reset on the server and erroring out
with an error page
because the user is no longer seen as logged in.

Is it possible that ServletExec is setting the cookie values again because
HttpClient is not
specifying cookies in the right way?  How can I debug this or even force the
the cookies to display
in the header properlyl?

Thanks,

Anthony Bargnesi

Reply via email to