On 07/21/2009 04:51 AM, EliG wrote:
> I am making my firts steps in Squid... and trying to see the content of the
> Html Response.
> In a future I will try to modify that content. The following code only shows
> me the content of the header but no content for the body. Please help.
> 
> in clientStream.cc:
> ~~~~~~~~~~~~~~
> ...
> void
> clientStreamCallback(clientStreamNode * thisObject, ClientHttpRequest *
> http,
>                      HttpReply * rep, StoreIOBuffer replyBuffer)
> {
>     clientStreamNode *next;
>     assert(thisObject && http && thisObject->node.next);
>     next = thisObject->next();
> 
>     debugs(87, 3, "clientStreamCallback: Calling " << next->callback << "
> with cbdata " << 
>            next->data.getRaw() << " from node " << thisObject);
>     //MY CODE STARTS HERE
>     if (rep)
>     {
>     	if (rep->content_type.pos("text/html"))
>     	{
>     		MemBuf *buf = rep->pack();
>     		debugs(87, 1, "My Code!!! The Header is: " << buf->content());
> 
>     		Packer p;
>     		MemBuf mb;
>     		mb.init();
>     		const HttpBody b = rep->body;
>     		httpBodyPackInto(&b, &p);
>     		packerToMemInit(&p, &mb);
> 
>     		debugs(87,1, "My Code!!! The Body is : " << mb.content());
>                           packerClean(&p);
>                           mb.clean();
>     	}
>     }
>     //MY CODE ENDS HERE
> 
>     next->callback(next, http, rep, replyBuffer);
> }
> 
I would recommend that you use eCAP which was designed for content
adaptation and has much higher-level interface than ClientStreams,
especially if you plan to update HTML later.
Good luck,
Alex.
Received on Fri Jul 24 2009 - 20:36:41 MDT
This archive was generated by hypermail 2.2.0 : Sat Jul 25 2009 - 12:00:08 MDT