You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by "Earle, Erik" <Er...@disney.com> on 2011/06/12 23:48:57 UTC
doing remap not in a remap plugin
I'm attempting to do remap in a regular plugin by rewriting the url in the PRE_REMAP step. Doesn't seem to work that way. Am I missing a step?
switch (event) {
case TS_EVENT_HTTP_PRE_REMAP:
...
if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc)!=TS_SUCCESS) {
TSError("couldn't retrieve request url");
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
return;
}
if (TSUrlSchemeSet(bufp, url_loc, TS_URL_SCHEME_HTTP, -1) == TS_ERROR) {
TSError("Unable to set scheme in URL in the HTTP Header");
}
if (TSUrlHostSet(bufp, url_loc, "www.w3.org", -1) == TS_ERROR) {
TSError("Unable to set host in URL in the HTTP Header");
}
if (TSUrlPortSet(bufp, url_loc, 80) == TS_ERROR) {
TSError("Unable to set port in URL in the HTTP Header");
}
if (TSUrlPathSet(bufp, url_loc, "/", -1) == TS_ERROR) {
TSError("Unable to set path in URL in the HTTP Header");
}
RE: doing remap not in a remap plugin
Posted by "Earle, Erik" <Er...@disney.com>.
Ha! I was calling TSSkipRemappingSet after TSHttpTxnReenable. All works.
-----Original Message-----
From: Earle, Erik [mailto:Erik.Earle@disney.com]
Sent: Sunday, June 12, 2011 11:16 PM
To: users@trafficserver.apache.org; ericb@apache.org
Subject: Re: doing remap not in a remap plugin
Thanks! Didn't seem to work, though. I'm using 2.1.8-unstable if that
makes a difference. Does what I'm trying to do seem like it should work?
bufp comes from the incoming TSHttpTxn Do I need to create a new URL to
make this work?
On 6/12/11 2:58 PM, "Eric Balsa" <er...@apache.org> wrote:
>Did you remember to use TSSkipRemappingSet(TSHttpTxn txnp, int flag) I
>added a while back so the SM jumps to POST_REMAP instead of requiring
>a remap? Give that a try...
>
>--Eric
>
>On Sun, Jun 12, 2011 at 2:48 PM, Earle, Erik <Er...@disney.com>
>wrote:
>> I'm attempting to do remap in a regular plugin by rewriting the url in
>>the
>> PRE_REMAP step. Doesn't seem to work that way. Am I missing a step?
>>
>> switch (event) {
>> case TS_EVENT_HTTP_PRE_REMAP:
>> ...
>> if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc)!=TS_SUCCESS) {
>> TSError("couldn't retrieve request url");
>> TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
>> return;
>> }
>> if (TSUrlSchemeSet(bufp, url_loc, TS_URL_SCHEME_HTTP, -1) ==
>>TS_ERROR) {
>> TSError("Unable to set scheme in URL in the HTTP Header");
>> }
>> if (TSUrlHostSet(bufp, url_loc, "www.w3.org", -1) == TS_ERROR) {
>> TSError("Unable to set host in URL in the HTTP Header");
>> }
>> if (TSUrlPortSet(bufp, url_loc, 80) == TS_ERROR) {
>> TSError("Unable to set port in URL in the HTTP Header");
>> }
>> if (TSUrlPathSet(bufp, url_loc, "/", -1) == TS_ERROR) {
>> TSError("Unable to set path in URL in the HTTP Header");
>> }
Re: doing remap not in a remap plugin
Posted by "Earle, Erik" <Er...@disney.com>.
Thanks! Didn't seem to work, though. I'm using 2.1.8-unstable if that
makes a difference. Does what I'm trying to do seem like it should work?
bufp comes from the incoming TSHttpTxn Do I need to create a new URL to
make this work?
On 6/12/11 2:58 PM, "Eric Balsa" <er...@apache.org> wrote:
>Did you remember to use TSSkipRemappingSet(TSHttpTxn txnp, int flag) I
>added a while back so the SM jumps to POST_REMAP instead of requiring
>a remap? Give that a try...
>
>--Eric
>
>On Sun, Jun 12, 2011 at 2:48 PM, Earle, Erik <Er...@disney.com>
>wrote:
>> I'm attempting to do remap in a regular plugin by rewriting the url in
>>the
>> PRE_REMAP step. Doesn't seem to work that way. Am I missing a step?
>>
>> switch (event) {
>> case TS_EVENT_HTTP_PRE_REMAP:
>> ...
>> if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc)!=TS_SUCCESS) {
>> TSError("couldn't retrieve request url");
>> TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
>> return;
>> }
>> if (TSUrlSchemeSet(bufp, url_loc, TS_URL_SCHEME_HTTP, -1) ==
>>TS_ERROR) {
>> TSError("Unable to set scheme in URL in the HTTP Header");
>> }
>> if (TSUrlHostSet(bufp, url_loc, "www.w3.org", -1) == TS_ERROR) {
>> TSError("Unable to set host in URL in the HTTP Header");
>> }
>> if (TSUrlPortSet(bufp, url_loc, 80) == TS_ERROR) {
>> TSError("Unable to set port in URL in the HTTP Header");
>> }
>> if (TSUrlPathSet(bufp, url_loc, "/", -1) == TS_ERROR) {
>> TSError("Unable to set path in URL in the HTTP Header");
>> }
Re: doing remap not in a remap plugin
Posted by Eric Balsa <er...@apache.org>.
Did you remember to use TSSkipRemappingSet(TSHttpTxn txnp, int flag) I
added a while back so the SM jumps to POST_REMAP instead of requiring
a remap? Give that a try...
--Eric
On Sun, Jun 12, 2011 at 2:48 PM, Earle, Erik <Er...@disney.com> wrote:
> I'm attempting to do remap in a regular plugin by rewriting the url in the
> PRE_REMAP step. Doesn't seem to work that way. Am I missing a step?
>
> switch (event) {
> case TS_EVENT_HTTP_PRE_REMAP:
> ...
> if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc)!=TS_SUCCESS) {
> TSError("couldn't retrieve request url");
> TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
> return;
> }
> if (TSUrlSchemeSet(bufp, url_loc, TS_URL_SCHEME_HTTP, -1) == TS_ERROR) {
> TSError("Unable to set scheme in URL in the HTTP Header");
> }
> if (TSUrlHostSet(bufp, url_loc, "www.w3.org", -1) == TS_ERROR) {
> TSError("Unable to set host in URL in the HTTP Header");
> }
> if (TSUrlPortSet(bufp, url_loc, 80) == TS_ERROR) {
> TSError("Unable to set port in URL in the HTTP Header");
> }
> if (TSUrlPathSet(bufp, url_loc, "/", -1) == TS_ERROR) {
> TSError("Unable to set path in URL in the HTTP Header");
> }