You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Jiří Podhorský <po...@gmail.com> on 2015/07/07 08:58:56 UTC

Binary body in plugin of traffic server

Hello,

can be binary body of http response accessed from some plugin of ATS,
for example
jpg picture?



I tried to look for it in TransformationPlugin
https://docs.trafficserver.apache.org/en/latest/api/classatscppapi_1_1TransformationPlugin.html,
but there is only sentence about producing binary body:
"size_t atscppapi::TransformationPlugin::produce ( const std::string &  )
This method is how a TransformationPlugin will produce output for the
downstream transformation plugin, if you need to produce binary data
this can still be done with strings by a call to string::assign() or
by constructing a string with string::string(char *, size_t). "

but method "consume" for loading data is not called for binary data in
my testing plugin, only for plaintext pages.

That is strange, because transformation plugin can receive and send
messages from and to another transformation plugin. So, next
transformation plugin should be able to accept binary body, when I can
send it by "produce" method.

Can you explain it for me?



I'm using trafficserver 5.3.


Thanks.
Jiri

Re: Binary body in plugin of traffic server

Posted by Brian Geffon <br...@apache.org>.
If you attach a transformation plugin the std::string will be populated
with whatever the body is, even if it's binary data. You'll need to use
.size()/.length() to determine the buffer size and then just make sure you
do not use string functions if it's binary data (check the content-type).

Brian

On Tue, Jul 7, 2015 at 2:58 PM, Jiří Podhorský <po...@gmail.com>
wrote:

> Hello,
>
> can be binary body of http response accessed from some plugin of ATS,
> for example
> jpg picture?
>
>
>
> I tried to look for it in TransformationPlugin
>
> https://docs.trafficserver.apache.org/en/latest/api/classatscppapi_1_1TransformationPlugin.html
> ,
> but there is only sentence about producing binary body:
> "size_t atscppapi::TransformationPlugin::produce ( const std::string &  )
> This method is how a TransformationPlugin will produce output for the
> downstream transformation plugin, if you need to produce binary data
> this can still be done with strings by a call to string::assign() or
> by constructing a string with string::string(char *, size_t). "
>
> but method "consume" for loading data is not called for binary data in
> my testing plugin, only for plaintext pages.
>
> That is strange, because transformation plugin can receive and send
> messages from and to another transformation plugin. So, next
> transformation plugin should be able to accept binary body, when I can
> send it by "produce" method.
>
> Can you explain it for me?
>
>
>
> I'm using trafficserver 5.3.
>
>
> Thanks.
> Jiri
>