You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Sudheer Vinukonda (JIRA)" <ji...@apache.org> on 2014/10/16 18:03:33 UTC

[jira] [Comment Edited] (TS-3137) Enhance header_rewrite to support set-redirect operator when used in global mode

    [ 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:02 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.

{{TSHttpTxnSetHttpRemapRedirect(TSHttpTxn txnp, TSMLoc url_m_loc)}}

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. Another (perhaps, not significant) difference is that the new API breaks off earlier in the state machine, while the latter approach treats the redirect-to url as the origin response and gets further along in trying to trigger a redirect follow etc (which is why, the redirect follow needs to be set to false).





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.

{{TSHttpTxnSetHttpRemapRedirect(TSHttpTxn txnp, TSMLoc url_m_loc)}}

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)

{{
        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);
}}

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. Another (perhaps, not significant) difference is that the new API breaks off earlier in the state machine, while the latter approach treats the redirect-to url as the origin response and gets further along in trying to trigger a redirect follow etc (which is why, the redirect follow needs to be set to false).




> 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)