Producing adapted body after noteVbContentDone()

Asked by Gernot Tenchio on 2011-03-14


i'm trying to hold back the adapted body until i can make the final decision whether to send the remaining body or not. So, in every noteVbContentAvailable() i'm writing the chunk into a temporary file and sending only 10 Bytes of the file back via abContent(). After receiving noteVbContentDone() and deciding whether to send or not. i'm trying to send the remaining data via noteAbContentAvailable()/abContent()/abContentShift(). This works fine for bodies < 65534 bytes. With larger bodies my adapter gets stuck into an endless loop with abContent() calls.

Any hints what i'm doing wrong?

I'm using squid-3.1.11 and libecap-0.0.3.


Question information

English Edit question
eCAP Edit question
No assignee Edit question
Solved by:
Gernot Tenchio
Last query:
Last reply:
Alex Rousskov (rousskov) said : #1

Sounds like a Squid bug to me. Consider trying libecap v0.2.0 and a recent Squid v3.2 daily snapshot which supports that libecap version and fixes a few body-handling corner cases. I do not know whether the same bugs will be fixed in Squid v3.1, but it would be useful to know whether recent Squid code changes help you.

OK, i've tried squid from bzr (3p2-ecap branch) and libecap v0.2.0 today. The result is the very same. This is what i see before the adapter gets stuck. The abContent* Messages are from my adapter.

==> abContent, sending 4096
2011/03/15 11:43:04.782| moveAbContent: up to 4096 bytes
2011/03/15 11:43:04.782| cbdataReferenceValid: 0x94288f0
2011/03/15 11:43:04.782| cbdataReferenceValid: 0x94249d8
2011/03/15 11:43:04.782| postAppend: added 4084 bytes [3460<=68994<=? 65534+1 pipe0x942af00 prod0x9428908 cons0x94249e0]
2011/03/15 11:43:04.782| cbdataReferenceValid: 0x94249d8
2011/03/15 11:43:04.782| cbdataReferenceValid: 0x94249d8
2011/03/15 11:43:04.782| cbdataLock: 0x94249d8=20
2011/03/15 11:43:04.782| The AsyncCall BodyConsumer::noteMoreBodyDataAvailable constructed, this=0x944d500 [call2153]
2011/03/15 11:43:04.782| cbdataReferenceValid: 0x94249d8
2011/03/15 11:43:04.782| cbdataLock: 0x94249d8=21
2011/03/15 11:43:04.782| cbdataUnlock: 0x94249d8=20
2011/03/15 11:43:04.782| will call BodyConsumer::noteMoreBodyDataAvailable(0x942af00*22) [call2153]
==> abContentShift, got: 4084, processed so far: 68994 bytes

Oh. My bad. In noteVbContentDone() i've called hostx->noteAbContentAvailable() in a 'while'-loop until processed == received Bytes.... This was the reason for my trouble.

Now it works fine with both libecap-0.0.3 and libecap-0.2.0.

Ngo Duc Huy (ndhuy-bn) said : #4

Hello Gernot,

I am very new in Squid+eCap. I am trying to write a sample as yours, but it is difficult for me.
Could you show me some code to send the adapted body in the noteVbContentDone?

Thank you very much!

joseph jose (joevypana) said : #5

i am having doubt in making adapted body. i have adapted requests, adding custom headers conditionally and everything works fine.. but i don't know how to add adapted body to a request.. if you don't mind could you please send me a note on it or a sample code segment?

I was about to post a question asking for help.. but saw this thread and thought you people can help.

Thanks in advance