You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Brian Geffon <bg...@linkedin.com> on 2011/12/07 07:02:22 UTC

Setting Response Content without transformation plugin

Hello,
I've run into a situation where I would like to set the response to a request to certain content. I know that i can use TSHttpTxnSetHttpRetBody and TSHttpTxnSetHttpRetStatus the problem with this is that TSHttpTxnSetHttpRetBody sets the HttpTransact::State->return_xbuf to accomplish this which has a limit of 2*1024 bytes, unfortunately this is far too low for what I'm trying to do. I understand that these API functions were probably originally designed to be used as error pages for the remap plugin, but I figure they could easily suit my purpose too.

I was thinking that about making the following changes to make this possible:
Change HttpTransact::State::return_xbuf to be a char * instead of char [2*1024].
In TSHttpTxnSetHttpRetBody I would use TSmalloc() to allocate the space and then free in State::destroy() and that way it could support an arbitrary sized response. I will happily submit a patch with these changes if no one sees any issues with my proposed modifications.

Of course, if there is another way to accomplish this same thing I would really appreciate any feedback.

Best,
Brian

Re: Setting Response Content without transformation plugin

Posted by Leif Hedstrom <zw...@apache.org>.
Brian Geffon wrote:
> Hello,
> I've run into a situation where I would like to set the response to a
> request to certain content. I know that i can use TSHttpTxnSetHttpRetBody
> and TSHttpTxnSetHttpRetStatus the problem with this is that
> TSHttpTxnSetHttpRetBody sets the HttpTransact::State->return_xbuf to
> accomplish this which has a limit of 2*1024 bytes, unfortunately this is
> far too low for what I'm trying to do. I understand that these API
> functions were probably originally designed to be used as error pages for
> the remap plugin, but I figure they could easily suit my purpose too.
>
> I was thinking that about making the following changes to make this
> possible:
> Change HttpTransact::State::return_xbuf to be a char * instead of char
> [2*1024].
> In TSHttpTxnSetHttpRetBody I would use TSmalloc() to allocate the space
> and then free in State::destroy() and that way it could support an
> arbitrary sized response. I will happily submit a patch with these changes
> if no one sees any issues with my proposed modifications.


What about TSHttpTxnErrorBodySet(), will it do what you want?  I honestly
don't know why we have two of these doing similar things... Probably worth
investigating (i.e. file a bug). Perhaps one or the other should be
deprecated ?

Looking at it, it's unfortunate that TSHttpTxnErrorBodySet() only takes an
"int" for length, but which "error" body is going to be > 2GB? :)

-- Leif

>
> Of course, if there is another way to accomplish this same thing I would
> really appreciate any feedback.
>
> Best,
> Brian
>