You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Daniel Chang <co...@gmail.com> on 2016/11/03 05:44:46 UTC

Reading TSIOBuffer content / bytes

Hi dev,

First email to this mailing list, excited to be here!  I'm new to ATS
development so please bear with me.

Briefly, I want to inspect the content data of HTTP responses for all of my
Transactions and store them on disk / in memory.  From a few hours of
reading, I've decided that creating a Transform plugin and reading from
VIOs is the correct way to do this, please correct me if I'm wrong.  I'm
working off of this example:

https://github.com/apache/trafficserver/blob/master/example/txn-data-sink/txn-data-sink.c

I want to grab the bytes from the TSIOBufferReader, but I'm poking around
and can't find a way to do this in 5.3.x.  I read the 7.1.0 docs which
seems to have a TSIOBufferReaderRead() function which seems to do exactly
what I want -- that is, consume N bytes from the TSIOBufferReader and copy
the data into a char *buffer.  Unfortunately it seems that function isn't
available in stable releases.

How would I do this in 5.3.x?  Thanks in advance!

Dan

Re: Reading TSIOBuffer content / bytes

Posted by Alan Carroll <so...@yahoo-inc.com.INVALID>.
Daniel, you might also look at examples/txn-data-sink in the source tree. If you only need output that might be simpler.
 

    On Friday, November 4, 2016 1:16 PM, Daniel Chang <co...@gmail.com> wrote:
 

 Thanks Nick, that was very helpful!  I found the relevant example in the
ironbee source on github.  The trick is to iterate through all blocks in
the TSIOBuffer and memcpy into a buffer.

For anyone that's interested:
https://github.com/ironbee/ironbee/blob/97b453afd9c3dc70342c6183a875bde22c9c4a76/servers/trafficserver/ts_headers.c#L300

Obviously, the TSIOBufferReaderRead() function in 7.1 would make this a lot
shorter to write.

On Thu, Nov 3, 2016 at 3:38 AM, Nick Kew <ni...@apache.org> wrote:

> On Wed, 2016-11-02 at 22:44 -0700, Daniel Chang wrote:
> > Hi dev,
> >
> > First email to this mailing list, excited to be here!  I'm new to ATS
> > development so please bear with me.
> >
> > Briefly, I want to inspect the content data of HTTP responses for all of
> my
> > Transactions and store them on disk / in memory.  From a few hours of
> > reading, I've decided that creating a Transform plugin and reading from
> > VIOs is the correct way to do this, please correct me if I'm wrong.
>
> Yes, that's the right basic approach.
>
> It's a while since I've worked on it, but the Ironbee plugin
> inspects response (and request) data, and has used basically
> the same APIs with every TS version since 2.x.  A look at that
> might be a good startingpoint.  Check the Ironbee site for
> the latest, as live development moved away from github.
>
> Or you might be able to use Ironbee for your purposes without
> any new plugin.
>
> --
> Nick Kew
>
>


   

Re: Reading TSIOBuffer content / bytes

Posted by Daniel Chang <co...@gmail.com>.
Thanks Nick, that was very helpful!  I found the relevant example in the
ironbee source on github.  The trick is to iterate through all blocks in
the TSIOBuffer and memcpy into a buffer.

For anyone that's interested:
https://github.com/ironbee/ironbee/blob/97b453afd9c3dc70342c6183a875bde22c9c4a76/servers/trafficserver/ts_headers.c#L300

Obviously, the TSIOBufferReaderRead() function in 7.1 would make this a lot
shorter to write.

On Thu, Nov 3, 2016 at 3:38 AM, Nick Kew <ni...@apache.org> wrote:

> On Wed, 2016-11-02 at 22:44 -0700, Daniel Chang wrote:
> > Hi dev,
> >
> > First email to this mailing list, excited to be here!  I'm new to ATS
> > development so please bear with me.
> >
> > Briefly, I want to inspect the content data of HTTP responses for all of
> my
> > Transactions and store them on disk / in memory.  From a few hours of
> > reading, I've decided that creating a Transform plugin and reading from
> > VIOs is the correct way to do this, please correct me if I'm wrong.
>
> Yes, that's the right basic approach.
>
> It's a while since I've worked on it, but the Ironbee plugin
> inspects response (and request) data, and has used basically
> the same APIs with every TS version since 2.x.  A look at that
> might be a good startingpoint.  Check the Ironbee site for
> the latest, as live development moved away from github.
>
> Or you might be able to use Ironbee for your purposes without
> any new plugin.
>
> --
> Nick Kew
>
>

Re: Reading TSIOBuffer content / bytes

Posted by Nick Kew <ni...@apache.org>.
On Wed, 2016-11-02 at 22:44 -0700, Daniel Chang wrote:
> Hi dev,
> 
> First email to this mailing list, excited to be here!  I'm new to ATS
> development so please bear with me.
> 
> Briefly, I want to inspect the content data of HTTP responses for all of my
> Transactions and store them on disk / in memory.  From a few hours of
> reading, I've decided that creating a Transform plugin and reading from
> VIOs is the correct way to do this, please correct me if I'm wrong.

Yes, that's the right basic approach.

It's a while since I've worked on it, but the Ironbee plugin
inspects response (and request) data, and has used basically
the same APIs with every TS version since 2.x.  A look at that
might be a good startingpoint.  Check the Ironbee site for
the latest, as live development moved away from github.

Or you might be able to use Ironbee for your purposes without
any new plugin.

-- 
Nick Kew