Forum Discussion
Jamey_Price_105
Nimbostratus
Jan 25, 2005Problem rewriting header attribute on HTTP code 302
I'm new to TCL as of yesterday, so if I'm doing something monumentally dumb, please pardon me.
Our application runs on a server on port 9080, clients access it via port 80 or 443. When...
unRuleY_95363
Jan 26, 2005Historic F5 Account
A couple of notes pertaining to our Tcl implementation.
a) You don't really need to declare local variables with the "variable" command. On first initialization, variables are automatically scoped into a per-connection, local scope.
b) As for the regexp command, you may have misinterpreted the optional nature of the matchVar and subMatchVar's. The matchVar is the complete matching string, where subMatchVar is the part within the parenthesis. In order to have a subMatchVar, you must have a matchVar (Tcl otherwise doesn't know whether you meant matchVar or subMatchVar). I often see the use of the variable '->' to make this appear more readable, however it is still just a garbage variable.
Eg: regexp .+:9080/(.*) [HTTP::header Location] -> whatiwant
c) In order to replace the header, you need to specify "replace" on the HTTP::header command. I am looking into why this ended up resulting in the bizarre error message you received, but it's probably some kind of bug.
d) Thanks for continuing to try!
Here is an updated example of your rule:
when HTTP_RESPONSE {
if { [HTTP::header Location] starts_with "http://dev.oursite.com:9080" } {
regexp .+:9080/(.*) [HTTP::header Location] garbage whatiwant
set thingy "http://dev.oursite.com/$whatiwant"
log "Thingy is $thingy"
HTTP::header replace Location $thingy
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects