Request Satisfaction when receiving POST Body

Asked by Jatin on 2019-12-12

Hi Alex,

I am trying to perform Request Satisfaction and instead of using blockVirgin I am trying to post my own special page for the POST request.

So I receive POST request and then followed by POST form body in Adapter::Xaction::noteVbContentAvailable() which I am buffering and based on certain form data I would like to block the access and post a html response page to the user. If I use blockVirgin I receive a Host application standard response page.

I looked at clam av adapter but it also uses blockVirgin method.

Can you please point me in the right direction ?

Question information

English Edit question
eCAP Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Jatin (jbhasin83) said : #1

Further information:
blockVirgin also does not work. Using blockVirgin it shows an icap error. Is it wrong to use blockVirgin after useVirgin. If yes then please suggest that what is the way to block request when based on Post Form request has to be blocked.

Jatin (jbhasin83) said : #2

I just reviewed the flow again: In request I do the following: I am not using useVirgin instead using useAdapted

if (hostx->virgin().body())
 receivingVb = opOn;
 hostx->vbMake(); // ask host to supply virgin body
 adapted = hostx->virgin().clone();
 Must(adapted != 0);

Alex Rousskov (rousskov) said : #3

To perform request satisfaction, the adapter must call useAdapted() with the desired response headers and then, if requested by the host, provide adapted body to the host application via noteAbContentAvailable(), noteAbContentDone() and associated adapter::xaction::ab*() methods.

useVirgin(), blockVirgin(), and useAdapted() are mutually exclusive -- they tell the host application about the corresponding mutually incompatible and final decision made by the adapter.

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

You are cloning a request. You want to create a response instead.

Jatin (jbhasin83) said : #4

Hi Alex,
At the request start I dont have POST body, just the POST header. I cannot make decision at the time to start a response. I want to check the POST body and then make a decision whether to block this request or not.

Alex Rousskov (rousskov) said : #5

> I want to check the POST body and then make a decision whether to block this request or not.

Then make a decision after you check the POST body. My original answer does not prescribe _when_ to make the decision. It applies to all decision making timings.

Jatin (jbhasin83) said : #6

Can you please point me to an example to how this can be done? The ecap adapter does not have this use case.

Alex Rousskov (rousskov) said : #7

The eCAP ClamAV adapter usually makes the decision after the virgin message body is received (and analyzed). I do not remember whether that adapter can generate its own responses though.

Jatin (jbhasin83) said : #8

Thanks it works now.