Forum Discussion

Zuke_254875's avatar
Zuke_254875
Icon for Altostratus rankAltostratus
Jul 19, 2017

Issues modifying XML content with stream profile & iRule

I've taken an iRule from another DevCentral post and modified it to fit my application.

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 {

 Check if response type is text
   if {[HTTP::header value Content-Type] contains "text/xml"}{

   Replace http:// with https://
   STREAM::expression {@http:\\/\\/applicationdomain@https:\\/\\/applicationdomain@}

   Enable the stream filter for this response only
  STREAM::enable

}

}

The stream profile is successfully replacing the HTTP: with HTTPS:, but is also including the additional backslash and a Silverlight (smh) error pops up

When I remove the second backslash in the iRule, the HTTP: is no longer replaced with HTTPS:, and I'm back to square one.

Any ideas on what I might be doing wrong? Thanks in advance!

  • Zuke's avatar
    Zuke
    Icon for Cirrostratus rankCirrostratus

    Alright, problem solved. I finally got the escaped characters in the XML files to match and substitute like I wanted. Hopefully this helps someone else.

     when RULE_INIT {
        set static::search "http:\\\\\\\/\\\\\\\/oldapplicationdomain"
        set static::replace "https:\\\/\\\/newapplicationdomain"
    }
    
    when HTTP_REQUEST {
    
         Disable the stream filter for all requests
            STREAM::disable
    
           HTTP::header remove "Accept-Encoding"
    }
    
    when HTTP_RESPONSE {
         Check if response type is text
           if {[HTTP::header value Content-Type] contains "text/xml"}{
    
       Replace http:// with https://
       STREAM::expression @${static::search}@${static::replace}@ 
    
       Enable the stream filter for this response only
       STREAM::enable
    
        }
    }