hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joan Balaguero" <joan.balagu...@grupoventus.com>
Subject Wrong Cookie value
Date Wed, 03 Oct 2012 14:40:30 GMT
Hello,

 

I’m receiving from a server a cookie with this value: ID=883390340340394

Set-Cookie: SITESERVER=ID=883390340340394

 

I’m not using any cookie store to process cookies, I’m working directly with
response headers. This is how I return back the response headers:

 

private String[] setResponseHeaders(HttpServletResponse response,
HttpResponse objResponse)

{

HeaderIterator it = objResponse.headerIterator();

             

while (it.hasNext())

{

 Header h          = it.nextHeader();

 String headerName  = h.getName();

   

  if (!isHopByHop(headerName)) response.addHeader(headerName, h.getValue());

}

}

 

Cookies are stored correctly in the browser.

 

The problem is when I send a new request with the cookies to another server.
I attach cookies to the HttpMessage in this way (dtoRequestHeader contains,
for every header, if it’s a hop-by-hop header and the list of its values).

 

private void setRequestHeaders(HttpMessage objMessage, dtoRequest request)

{

  Iterator<Map.Entry<String, dtoRequestHeader>> it =
request.getHeaders().entrySet().iterator();

         

  while (it.hasNext()) 

  {

  Map.Entry<String, dtoRequestHeader> entry = it.next();

   String headerName                         = entry.getKey();

   dtoRequestHeader requestHeader            = entry.getValue();

          

   if (!requestHeader.esHopByHop()) 

   {

    for (String value : requestHeader.getValues())
objMessage.addHeader(headerName, value);

   }

  }

}

 

When the destination server tries to get cookies, the value of SITESERVER is
ID. If you inspect the request, the Cookie: SITESERVER=ID=883390340340394 is
present, but the HttpServletRequest can’t process it correctly, due to the
equals symbol (I suppose).

 

I’ve read a lot about correct or incorrect values within cookies, but the
solution is not clear for me. 

 

Cany anybody help me? If I have a cookie stored in the browser with a value,
for example, ID=883390340340394, what would it be the correct method to send
this value from httpClient?

 

Thanks,

Joan.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message