[ 
https://issues.apache.org/jira/browse/TS-3137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14173896#comment-14173896
 ] 

Sudheer Vinukonda edited comment on TS-3137 at 10/16/14 4:38 PM:
-----------------------------------------------------------------

The attached patch proposes to add the below new TS convenience API (the API 
(including the name) is yet to be reviewed and approved by the API review 
process) to be able to trigger a 3xx response to the client along with using 
body_factory templates for the redirect response.

{code}
       TSHttpTxnSetHttpRemapRedirect(TSHttpTxn txnp, TSMLoc url_m_loc)
       TSHttpTxnFollowRedirect(res.txnp, false);
{code}

Discussed with [~zwoop] and [~amc] on the IRC and they have suggested the below 
workaround with existing TS API (NOTE: this is just an example for functional 
equivalency and needs more cleaning up - e.g. the TSstrdup() needs to be 
removed etc)

{code}
        TSHttpTxnRedirectUrlSet(res.txnp, TSstrdup(value.c_str()), 
strlen(value.c_str()));
        char* err_buf = "redirected to..."; 
        TSHttpTxnErrorBodySet(res.txnp, TSstrdup(err_buf), strlen(err_buf), 
NULL);
        TSHttpTxnFollowRedirect(res.txnp, false);
{code}

Both the above approaches work as far as sending the 3xx response to the client 
is concerned. The advantage of the new TS API is that, it allows to use 
body_factory templates for sending the response, while the second approach 
doesn't permit that right now, unless there are more changes in the core.





was (Author: sudheerv):
The attached patch proposes to add the below new TS convenience API (the API 
(including the name) is yet to be reviewed and approved by the API review 
process) to be able to trigger a 3xx response to the client along with using 
body_factory templates for the redirect response.

{code}
     TSHttpTxnSetHttpRemapRedirect(TSHttpTxn txnp, TSMLoc url_m_loc)
     TSHttpTxnFollowRedirect(res.txnp, false);
{code}

Discussed with [~zwoop] and [~amc] on the IRC and they have suggested the below 
workaround with existing TS API (NOTE: this is just an example for functional 
equivalency and needs more cleaning up - e.g. the TSstrdup() needs to be 
removed etc)

{code}
        TSHttpTxnRedirectUrlSet(res.txnp, TSstrdup(value.c_str()), 
strlen(value.c_str()));
        char* err_buf = "redirected to..."; 
        TSHttpTxnErrorBodySet(res.txnp, TSstrdup(err_buf), strlen(err_buf), 
NULL);
        TSHttpTxnFollowRedirect(res.txnp, false);
{code}

Both the above approaches work as far as sending the 3xx response to the client 
is concerned. The advantage of the new TS API is that, it allows to use 
body_factory templates for sending the response, while the second approach 
doesn't permit that right now, unless there are more changes in the core.




> Enhance header_rewrite to support set-redirect operator when used in global 
> mode
> --------------------------------------------------------------------------------
>
>                 Key: TS-3137
>                 URL: https://issues.apache.org/jira/browse/TS-3137
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Plugins
>    Affects Versions: 5.0.1
>            Reporter: Sudheer Vinukonda
>            Assignee: Sudheer Vinukonda
>             Fix For: 5.2.0
>
>         Attachments: TS-3137.diff
>
>
> We have a use case to redirect all incoming users of certain type (e.g. old 
> version of certain browsers) to some pre-determined site. 
> header_rewrite supports the set-redirect operator to achieve this, but, 
> currently, this only works on a remap mode. We have a very large number of 
> remap rules (in the order of 20K+), so, supporting set-redirect in global 
> mode would make it easier for operation. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to