simplest test for REQMOD vs. RESPMOD

Asked by Tom

What is the simplest or most appropriate test that I can make, in Xaction::start(), to determine whether this instance is a REQMOD or RESPMOD?

The best suggestion that I've found was the code sample Alex provided to get the URI, using either hostx->virgin() or hostx->cause(). The comments in the libecap source for host\xaction.h say the virgin() result is "always present" and the result for cause() seems to be only for the response. Would that imply a test for hostx->cause() is the appropriate way to test for whether this is a REQMOD or RESPMOD? Is there some other, better or preferred approach?

Thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Solved by:
Alex Rousskov
Solved:
Last query:
Last reply:
Revision history for this message
Best Alex Rousskov (rousskov) said :
#1

Ideally, your libecap::adapter::Service::makeXaction() implementation should tell the transaction which service it belong to. Technically, REQMOD service must be different from the RESPMOD service (e.g., each should have a unique service URI).

It is theoretically possible to have a RESPMOD transaction without a corresponding request, but as a practical matter, you may indeed rely on cause() being nil for and only for REQMOD transactions.

Revision history for this message
Tom (web-l) said :
#2

Ah, that makes so much sense! I've been trying to implement both REQMOD and RESPMOD in the same service only because the examples only included one service and I thought they had to be handled by the same service. Now it makes so much sense. I should create a second service with a unique uri (found via Adapter::Service::uri()) and then register that second service with libecap::RegisterService(new Adapter::MyRespModService). The squid.conf file references the uri with each ecap_service specification, so then I just change that to match.

Many other things make sense to me now that I realize that. Thank you!

Revision history for this message
Tom (web-l) said :
#3

Thanks Alex Rousskov, that solved my question.