Hi Traffic Server Gurus, Would appreciate some help here -- How can I access the underlying string or char* for the body of the server response? There are many functions for working with server response headers - including URL, mime type, etc, but I see nothing for the body itself.
I am trying to write a plugin with behavior that depends on the body of the response from the http server. Thanks, Manish How do I access the actual string or char* > representing the body here? The data seems to be hidden below a few levels > of buffers and abstractions: > > if (towrite > 0) { > /* Copy the data from the read buffer to the output buffer. */ > if (TSIOBufferCopy(TSVIOBufferGet(data->output_vio), > TSVIOReaderGet(input_vio), towrite, 0) == TS_ERROR) { > TSError("[null-plugin] unable to copy IO buffers\n"); > goto Lerror; > } On Tue, Nov 30, 2010 at 7:14 AM, Manish Pandey <mpan...@alumni.cmu.edu> wrote: > Hi Eric, > Thanks for the pointers. >>1. With a transformation plugin you could 'print' the full response -- but >> where do you want to print it? > I'd like to print it as a debug message to stdio/stderr on the window in > which the program is running, and check on the transformations that are > applied to it. > 2. The null-transform plugin can be the basis of the plugin I want to > develop, but a couple of questions. Here is the code snippet which seems to > do the actual copying. How do I access the actual string or char* > representing the body here? The data seems to be hidden below a few levels > of buffers and abstractions: > > if (towrite > 0) { > /* Copy the data from the read buffer to the output buffer. */ > if (TSIOBufferCopy(TSVIOBufferGet(data->output_vio), > TSVIOReaderGet(input_vio), towrite, 0) == TS_ERROR) { > TSError("[null-plugin] unable to copy IO buffers\n"); > goto Lerror; > } > > Thanks, > Manish > On Sun, Nov 28, 2010 at 10:47 PM, Eric Balsa <er...@apache.org> wrote: >> >> Hi Manish, >> >> 1. With a transformation plugin you could 'print' the full response -- >> but where do you want to print it? >> >> 2. There is no HTML parsing inside TrafficServer. TS does not care >> about content; it proxies/caches *anything* as long as it's served >> over HTTP/HTTPS. >> >> To solve your problem, you would need to develop a transformation >> plugin >> ( http://trafficserver.apache.org/docs/v2/sdk/HTTPTransformationPlugins.html) >> and do some simple string parsing on the buffer. >> >> There are a few plugin examples available to get you started at: >> >> http://svn.apache.org/repos/asf/trafficserver/traffic/trunk/example/null-transform/ >> >> http://svn.apache.org/repos/asf/trafficserver/traffic/trunk/example/bnull-transform/ >> >> http://svn.apache.org/repos/asf/trafficserver/traffic/trunk/example/append-transform/ >> >> Regards, >> --Eric >> >> On Sun, Nov 28, 2010 at 9:05 PM, Manish Pandey <manis...@gmail.com> wrote: >> > Hi folks, >> > >> > I am developing a trafficserver plugin, and would like to find out >> > 1. How can I print a origin server response sent to the trafficserver, >> > e.g., >> > the html document with embedded javascript etc. >> > 2. Also, how can I detect specific strings in the response to do >> > response >> > filtering? Is there any html parser that is available >> > in TS that I can use for this? >> > >> > Any pointers will be appreciated. >> > >> > Thanks, >> > Manish >> > > >