Forum Discussion

Narendra_Babu's avatar
Narendra_Babu
Icon for Nimbostratus rankNimbostratus
Feb 17, 2015

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

 

5 Replies

  • shaggy's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    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

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    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