Changing Cookie in HTTP Header breaks POST request

Asked by Jatin on 2014-06-11

Hello,

I am using following code to change cookie. When I do this for a GET request then it's fine but POST request breaks with 500 internal server error. Can you please suggest what I could be doing wrong here?

   static const libecap::Name name("Cookie");
   adapted->header().removeAny(name);
   const libecap::Header::Value value = libecap::Area::FromTempString("New Cookie String");
   adapted->header().add(name, value);

Thanks,
Jatin

Question information

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Solved by:
Jatin
Solved:
2014-06-12
Last query:
2014-06-12
Last reply:
2014-06-11
Jatin (jbhasin83) said : #1

I have now found that the 500 Internal Server Error Comes even when I useAdapted Content. So basically I say:

adapted = hostx->virgin().clone();

and without changing any content I ask it to use adapted content and still I see the 500 internal server for POST request. But if I say useVirgin then I dont get any error.

Please suggest that how can I resolve this error.

Jatin (jbhasin83) said : #2

It produced following in browser:

X-Squid-Error:ERR_ICAP_FAILURE 0

Alex Rousskov (rousskov) said : #3

POST and PUT requests come with a body. To adapt such requests, you need to take care of both the headers (which you do) and the body (which you may have forgotten about). See the passthru and modifying adapter samples as well as host::Xaction::noteAbContentAvailable/Done() methods.

There is currently no way to tell the host application that it can reuse the virgin body with the adapted header. Such an interface may be added to eCAP in the future.

Please note that requests other than PUT and POST may have a body as well. Use Message::body() to detect message body presence (instead of using the request method).

Jatin (jbhasin83) said : #4

Thanks, Alex that solved my question.