STREAM Expression with exceptions

Hi all,

In my HTTP page (including form), i want to replace a string domain.com to domainservice.com But i don’t want to change if string is @domain.com.

I tried with multiple expressions with no luck

Can some one help me on this

Thanks

are you using the stream profile or stream profile + iRule to apply your stream patterns?

Hi Narendra,

in case you are using iRules the following will hopefully work for you as well:

when HTTP_RESPONSE {
    STREAM::expression "\[^@\]comain\.comdomainservice\.com"
    STREAM::enable
}

Thanks, Stephan

You might be able to use a “null” stream match along with STREAM_MATCHED event.

Look at: DevCentral - An F5 Technical Community

I don’t know exactly how stream works, that is does it “rescan” a string after it has found and done a a replace. Could you specify a second like:

"domain\.comdomainservice\.com \@domainservice\.com\@domain.com"

Not sure if you have to escape and @ sign.

Try this:

when HTTP_REQUEST {
    Disable the stream filter for all requests
   STREAM::disable

    LTM does not uncompress response content, so if the server has compression enabled
    and it cannot be disabled on the server, we can prevent the server from 
    sending a compressed response by removing the compression offerings from the client
   HTTP::header remove "Accept-Encoding"
}    
when HTTP_RESPONSE {
    STREAM::expression "@domain\.com domain\.comdomainservice.com"
    STREAM::enable
}
when STREAM_MATCHED {
    set matched_string [string tolower [STREAM::match]]
    if {$matched_string starts_with "@domain.com"} {
        STREAM::replace
        return
    }
}

Hi again,

the following approach seems to work.

It seems to follow a longest match approach.

So the order of pattern mappings does not matter.

when HTTP_REQUEST {
    STREAM::disable
}
when HTTP_RESPONSE {
    STREAM::expression {@domain\.com@domain.com domain\.comdomainservice.com}
    STREAM::enable
}

Tested on v11.5.1HF8.

Thanks, Stephan