Hello,
Im receiving from a server a cookie with this value: ID=883390340340394
Set-Cookie: SITESERVER=ID=883390340340394
Im not using any cookie store to process cookies, Im 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 its 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 cant process it correctly, due to the
equals symbol (I suppose).
Ive 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.