How E-Cap work ?

Asked by Danny

Hi,

Previously using i-cap and now trying to us e-cap, everything in Squid3.1 + E-Cap hooking up OK and now trying to code a custom E-Cap module to achieve what we wanted but I find it very hard to understand how E-Cap really work, especially its FLOW for each stage of the following:

[Http Request]
Browser ----> Squid + E-Cap ----> Web Server

[Http Response]
Browser <---- Squid + E-Cap <---- Web Server

     Using adapter_modifying.cc as a reference, we know there are 2 classes ie. Class Service and Class Xaction ? With referring to the above Http Request+Response. I would like to know which function get called first and what we can do and achieve in each of the functions. Of course in the sample adapter_modifying.cc, it show how to add/remove Response header and replace some string in Response chunks. Other than these, I am totally blur about the flow of each of the functions inside adapter_modifying.cc. This raise some questions like below:

1. How to modify Http Request Header (Before sending to web server ) ?

2. How to modify Http Response Header (After receiving from Web Server) ?
     - The adapter_modifying.cc showing add/remove Response header to ALL Responses, if we only want to remove some Header for specific content-type and file like index.html, how do we do it ?

3. How to modify Http Request POST Data (Before sending to web server ) ?

4. How to modify Http Request Body (After receiving from Web Server) ?
    - The adapter_modifying.cc showing a basic string replace to ALL Responses, if we only want to replace some string for specific content-type and file like index.html, how do we do it ?

Anyone, pls show us the light.

Thanks a lot.

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

In general, eCAP message flow is very similar to ICAP message flow.

You seem to assume that the modifying adapter sample adapts only responses. This is incorrect. The sample adapts messages. If you configure your host application to use that sample adapter in REQMOD, it will adapt requests. If you configure your host application to use the adapter in RESPMOD, it will adapt responses. If you configure your host application to use the adapter in both REQMOD and RESPMOD, it will adapt both requests and responses.

With the exception of methods like cause() and firstLine(), the eCAP API does not depend on the message kind being adapted. Your own adapter can be, of course, written to work with only one message kind and you could instruct your users to configure their host applications accordingly. This is, again, very similar to how the ICAP protocol works.

You can call useVirgin() to refuse to adapt messages that you are not interested in.

The sample adapters are meant to be very simple and do not illustrate all eCAP capabilities. You may want to study eCAP ClamAV adapter for an example of a production adapter.

Revision history for this message
Danny (penkween) said :
#2

Thanks Alex Rousskov, that solved my question.