Forum Discussion
C_D_18583
Nimbostratus
Nov 20, 2006Replacing in the URI ; http -> https and port 80 -> 443
What is the easiest way to rewrite the following string? Replacing in the URI http -> https and port 80 -> 443
Before:
https://testlab-d.tdx.dorion.com/amserver/UI/Login?goto=http%3A%2F%2Ftestlab-d.tdx.dorion.com%3A80%2Fperform%2FLogin.do%3FLANGUAGE%3DEN
After:
https://testlab-d.tdx.dorion.com/amserver/UI/Login?goto=https%3A%2F%2Ftestlab-d.tdx.dorion.com%3A443%2Fperform%2FLogin.do%3FLANGUAGE%3DEN
Thanks in Advance!
18 Replies
- C_D_18583
Nimbostratus
Thanks - C_D_18583
Nimbostratus
schwiddy - The built-in string map TCL command is probably what you'll want.
when HTTP_REQUEST { set query [HTTP::query] set new_query [string map {goto=http% goto=https% %3A80% %3A443% %3DEN %3DFR} $query] HTTP::query $new_query }
when HTTP_REQUEST { HTTP::query [string map {goto=http% goto=https% %3A80% %3A443% %3DEN %3DFR} [HTTP::query]] }
- C_D_18583
Nimbostratus
Thanks Joe - Steve_Manuel_11
Nimbostratus
Hi Joe; - some of our variables are cached in the initial request so after making modifications of them (in your case with the HTTP::query command), if you try to access the value it will still return the original cached value. The value is changed, just not in the accessor variable. Have you verified that you servers are not receiving the correct value either by a log file or tcpdump?
- Steve_Manuel_11
Nimbostratus
Hi Joe; - hoolio
Cirrostratus
The example worked for me:when RULE_INIT { test the string map replacement set aString "" unset aString log local0. " " set aString "/amserver/UI/Login?goto=http%3A%2F%2Fsecureinternal-d.tmi.telus.com%3A80%2Feperformance%2FLogin.do%3FLANGUAGE%3DEN" log local0. "original: $aString" log local0. "new : [string map {goto=http% goto=https% %3A80% %3A443%} $aString]" } when HTTP_REQUEST { test the actual replacement in the URI if { [HTTP::uri] contains "goto"} { HTTP::query [string map {goto=http% goto=https% %3A80% %3A443%} [HTTP::query]] log local0. "this doesn't get updated: [HTTP::query]" log local0. "this is the actual value that gets set: [string map {goto=http% goto=https% %3A80% %3A443%} [HTTP::query]]" } }
- Steve_Manuel_11
Nimbostratus
Aaron; - hoolio
Cirrostratus
If you're setting the query to the updated value using HTTP::query and string map, you shouldn't need to modify the URI.
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