Share binary data between Request and Response Transaction

Asked by Jatin

Hi Alex,

I am using squid and ecap. I am using adaptation_masterx_shared_names to share information between request and response transaction. I am able to do that successfully for string data. But I am not sure if its possible to do it for binary data. I am looking for suggestions from you if it can be done and how and may be if you have an example for the same.

If it cannot be done at all then I think one option would be to convert binary into hexadecimal string. Do you have any other ideas as I would like to as less computation as possible.

Thanks,

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

I hope that libecap correctly handles binary metadata values -- no special handling is needed to pass them around. However, I am less optimistic about Squid -- some of its code may assume that meta-header values cannot have ASCII NUL (i.e. '\0') characters because that Squid code originally dealt with just HTTP and ICAP headers, and those headers cannot have NULs.

* If your REQMOD and RESPMOD adaptation services do not share memory, then my recommendation would be to encode the value (using whatever encoding you want as long as its output produces valid HTTP header field values; hex is fine).

* If your REQMOD and RESPMOD adaptation services share memory, then you can also consider sending an index or key of some sort (could be a number printed as plain text digits). The receiving transaction will then lookup the object (in some storage shared by all transactions) using that index/key.

Revision history for this message
Jatin (jbhasin83) said :
#2

Hi Alex,

You are right. The value is lost in ecap/XactionRep.cc in function updateHistory when updateXxRecord function is called which then does a strlen on the value and hence it does not store the value correctly. If you know the function call can be changed to store the value so that it does use strlen instead store the value using memcpy.

What are possible ways REQMOD and RESPMOD share memory. I know of shared memory using shm* calls. Are there any other ways you would recommend.

Thanks

Revision history for this message
Alex Rousskov (rousskov) said :
#3

When REQMOD and RESPMOD services live in the same library they can share memory just like any two functions inside the same program can share memory, no shm_ APIs are required for that.

Revision history for this message
Alex Rousskov (rousskov) said :
#4

> If you know the function call can be changed to store the value so that it does use strlen instead store the value using memcpy

Squid modificaitons are outside this Answers scope, but I would be worried that this is not the only place where strlen() or equivalent is used inside Squid when it comes to handling meta-headers. Too much Squid code may assume HTTP-like character set for those field values.

Revision history for this message
Jatin (jbhasin83) said :
#5

Thanks

Revision history for this message
Jatin (jbhasin83) said :
#6

Thanks Alex Rousskov, that solved my question.