Hi Jacques,

HttpClient automatically processes cookie in the response and adds any new cookies to the associated HttpState. Take a look at HttpClient.getState() and HttpState.getCookies(). There is also some more info on cookie parsing at <http://jakarta.apache.org/commons/httpclient/cookies.html>. You can also get the raw cookie headers from a response by calling HttpMethod.getResponseHeader("Set-Cookie") on the executed method.

Mike

On Dec 22, 2003, at 10:27 AM, aruba bulk wrote:

Hi there (pls ignore my previous post)

I'm using HttpClient to write a Cactus unit test. I'd
like to simulate a browser, sending a cookie to the
server with a request. So the cookie originates at the
client side :

HttpClient client = new HttpClient();
HttpMethod method = new getMethod(url);
String cookieValue = "testValue";
String cookieName = "testname";
Cookie cookie = new Cookie("localhost", cookieName,
cookieValue);
cookie.setPath("/");

HttpState httpState=new HttpState();
httpState.addCookie(cookie);
client.setState(httpState);

// Execute the method.
int statusCode = -1;
try {
  statusCode = client.executeMethod(method);
} catch (HttpRecoverableException e) {}
  catch (IOException e) {}

// Read the response body.
byte[] responseBody = method.getResponseBody();

My question is this : I need to check whether the
server has set any additional cookies in the response.
How do i do this ?

Any help greatly appreciated.

Regards
Jacques



=====
"All one's life is music, if one touches the notes rightly, and in time."
- John Ruskin


---------------------------------------------------------------------
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]



Reply via email to