wlepkin_98758
Jan 30, 2012Nimbostratus
string trimleft, and assigning HTTP::uri
Hi --
I'm trying to use the 'string trimleft' function to change the URI, and must be doing something wrong. Here's what I've got, with lots of log statements so I can see what's going on:
when HTTP_REQUEST {
set loweruri [string tolower [HTTP::uri]]
log local0. "String-to-lower URI is $loweruri"
if { $loweruri starts_with "/chart" } then
{
log local0. "Original URI is [HTTP::uri]"
log local0. "string trimleft = [string trimleft [HTTP::uri] /chart]"
HTTP::uri [string trimleft [HTTP::uri] /chart]
log local0. "New URI is [HTTP::uri]"
log local0. "Redirecting to http://ifp-vip:8080[HTTP::uri]"
HTTP::redirect ]
unset loweruri
}
}
The point being that if the URI starts with '/chart' then you want to strip that off, and send what's left to a different host:port.
If I send request: http://denfpot-vip/chart/abc
This is what shows up in the log:
: String-to-lower URI is /chart/abc
: Original URI is /chart/abc
: string trimleft = bc
: New URI is /chart/abc
: Redirecting to http://ifp-vip:8080/chart/abc
So, this prompts two question:
- why is trimleft returning 'bc' instead of '/abc'?
- why is the URI not getting reassigned (even to the wrong thing)?
Software version is 9.3.1, perhaps that's relevant.
As always, thanks much for your help.
WDL