Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

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@" "@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

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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@}
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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

0
Comments on this Answer
Comment made 1 month ago by Yannick 26

Hi,

Thanks for your reply.

I need to replace 'http://site.sub.domain.com' by 'https://site.domain.com'.

This is ok, but I need to replace the url (in some js) in this format too : 'http:\/\/site.sub.domain.com' by 'https:\/\/site.domain.com'

It content a '\' in front of '/' in the page.

So I try :

STREAM::expression [list "@http:././site.sub.domain.com@https:\\/\\/site.domain.com@" "@http://site.sub.domain.com@https://site.domain.com@"]

But I don't know how to match the '\' and the '\\' in a list seems generate an error.

0