Forum Discussion
Backslash in STREAM::expression
Hello,
I have some trouble to replace every occurence that match something like 'http:\/\/site.sub.domain.com' by 'https:\/\/site.domain.com'.
My irule looks like the following :
when HTTP_RESPONSE {
if { [HTTP::header value Content-Type] contains "text" } {
STREAM::disable
STREAM::expression [list "@http:\\/\\/site.sub.domain.com@https:\\/\\/site.domain.com@" "@http://site.sub.domain.com@https://site.domain.com@"]
STREAM::enable
}
}
This give me an error : TCL error: /Common/rewrite_site - Illegal argument (line 3) invoked from within "STREAM::expression [list "@http:\/\/site.sub.domain.com@https:\/\/site.domain.com@" "@;]"
So, I do some test :
STREAM::expression "@http:\\/\\/site.sub.domain.com@https:\\/\\/site.domain.com@"
-> Do not match
STREAM::expression "@http:././site.sub.domain.com@https:\\/\\/site.domain.com@"
-> OK -> replace 'http:\/\/site.sub.domain.com' by 'https:\/\/site.domain.com'
STREAM::expression [list "@http:././site.sub.domain.com@https:\\/\\/site.domain.com@" "@http://site.sub.domain.com@https://site.domain.com@"]
-> same error as above
From these tests, my first problem is that I don't know how to match a '\' but can work arround with '.' and my second problem is that it seems that when I try to use the '\' in a list, it generate an error.
Can someone show me the right way to do that ?
Thanks
Resolved, it work with this syntaxe :
STREAM::expression {@http:\\/\\/site.sub.domain.com@https:\/\/site.domain.com@ @http://site.sub.domain.com@https://site.domain.com@}
- youssef1Cumulonimbus
Hi Yannick,
You don't need backslash:
https://devcentral.f5.com/questions/basic-http-stream-profile
did you try just:
when HTTP_RESPONSE { if { [HTTP::header value Content-Type] contains "text" } { STREAM::disable STREAM::expression {@http://site.sub.domain.com@https://site.domain.com@} STREAM::enable } }
You can also a rewrite profil instead stream profil... Did you test it? please see my response in this post:
https://devcentral.f5.com/questions/intenal-server-responds-internal-url-to-external-clients-60392
Regards
- Yannick_385905Nimbostratus
Resolved, it work with this syntaxe :
STREAM::expression {@http:\\/\\/site.sub.domain.com@https:\/\/site.domain.com@ @http://site.sub.domain.com@https://site.domain.com@}
Recent Discussions
Related Content
* 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