On Fri, 19 Apr 2013 22:54:47 +0100
Nick Kew <[email protected]> wrote:
> I'll attach a mini demo-plugin that reproduces the problem.
> The essence of it can be boiled down to:
Magic sauce here.
This fails:
TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc);
iobufp = TSIOBufferCreate();
TSHttpHdrPrint(bufp, hdr_loc, iobufp);
readerp = TSIOBufferReaderAlloc(iobufp);
This works:
TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc);
iobufp = TSIOBufferCreate();
readerp = TSIOBufferReaderAlloc(iobufp);
TSHttpHdrPrint(bufp, hdr_loc, iobufp);
We can get away with losing the buffer in the iobuf
provided the reader buf was set *before* trashing it. Ouch!
I thought I got the first originally from an example plugin,
though I can't find it in current versions. It is still there
in proxy/InkAPITest.cc at line 3445:
TSIOBuffer iobuf = TSIOBufferCreate();
TSHttpHdrPrint(bufp1, hdr_loc1, iobuf);
TSIOBufferReader iobufreader = TSIOBufferReaderAlloc(iobuf);
Hmmm ....
--
Nick Kew