How to add a new (or adapt an existing) message body?

Asked by joseph jose

I want to send an adapted request conditionally.. i am able to set header contents like type, length, status line and all to adapted request.. but how to add body to an adapted request/response?? could you please send a note on it or a sample code segment?.

My host application is squid 3.3

Question information

English Edit question
eCAP Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Alex Rousskov (rousskov) said :

There is almost no difference between handling request bodies and handling response bodies. There are two cases to consider:

1. Adding a body to a new adapted request is essentially the same as adding a body to a new adapted response. After creating a new request using Host::newRequest() and before calling host::xaction::useAdapted(), you need to call Message::addBody() method to add an [empty] body to the newly created request message. Then you do exactly what the code mentioned in #2 below does.

2. Adapting an existing request body is essentially the same as adapting an existing response body. Several published adapters adapt existing message bodies so you have examples to look at. To start with, look for the sample code that calls host::Xaction::noteAbContentAvailable() and handles adapter::xaction::abContent*() calls from the host application.

Can you help with this problem?

Provide an answer of your own, or ask joseph jose for more information if necessary.

To post a message you must log in.