Hi Squid Users,
I'm currently trying to make squid being able to insert some content at the
end of fetched text/html objects. I'm facing some weird issue (to me), that may
need light from squid experts ;-) Hope squid-users is an appropriate place for
this question.
The content insertion function is added in http.c, and basically does the
following :
- Check if entry->mem_obj->reply->header has a "text/html" Content-Type, and
check if entry->mem_obj->reply->sline.status == HTTP_OK
- Locate the insertion point in entry->mem_obj->data_hdr.tail->data (let's say
before </body>)
- Then I modify the content itself, by refreshing refresh_timestamp, put '\0'
at insertion point, reduce entry->mem_obj->data_hdr.tail->len and
entry->mem_obj->inmem_hi by the size of the stripped part, and finally
storeAppend() my content (+the stripped part).
This function is inserted in httpAppendBody(), in a place I guess the
object is entirely fetched (and httpAppendBody() not called anymore), for
example after the "Verified and done with the reply" comment.
The problem is that, when I log dump entry data's tail before returning the
insertion function, the content looks as expected : "</center>MY CONTENT GOES
HERE</body></html>". But the final content received by the browser looks like
this : "</center></body></html>S HERE</body></html>", as if the buffer was
overwritten by the original content... I'm a bit puzzled here, and almost sure
that httpAppendBody() and storeAppend() are not called anymore for the given
request.
I'm quite new to digging into squid's code, and I think my mistake is
calling the function in the wrong place. As far as I understand the code,
httpAppendBody() is called every time there is datas available in httpReadReply
(and the header is already processed). I tried different places in
httpAppendBody, with different results : sometimes my code is not called at
all, sometimes I have the described behavior, and sometimes an alternation of
correct and uncorrect behavior (with consecutive requests).
Does anyone have some hint or advice ?
Thanx a lot
--
Julien