Forum Discussion

Igor_Morgado_38's avatar
Icon for Nimbostratus rankNimbostratus
Feb 03, 2011

HTTP response data (html body) rewrite - questions


Im trying to apply a stream profile to change a string in html response from server the source is:

body  marginheight="0" marginwidth="0" rightmargin="0" leftmargin="0" topmargin="0"  onload="onLoadBody()"

I want to set as

body  marginheight="0" marginwidth="0" rightmargin="0" leftmargin="0" topmargin="0"

Creating a stream profile seems not work, my actual configuration in stream profile is:

Source: onload="onLoadBody()"
Target:  (empty) tried put some placeholder  and also didnt worked.

My VS has the following configs:

virtual vs_mgp {
   snat automap
   pool mgp_http_pool
   ip protocol tcp
   persist mgp_pr_srcaddr
   profiles {
      mgp-http-lan-optimized-caching {}
      mgp-oneconnect {}
      mgp-tcp-lan-optimized {
      mgp_remove_onload {}
      tcp-wan-optimized {
ltm profile http mgp-http-lan-optimized-caching {
    defaults-from http-lan-optimized-caching
    insert-xforwarded-for disabled
    ramcache disabled
    ramcache-uri-exclude none
    ramcache-uri-include none
    ramcache-uri-pinned none
    response-chunking rechunk
ltm profile one-connect mgp-oneconnect {
    defaults-from oneconnect
ltm profile stream mgp_remove_onload {
    defaults-from stream
    source "onload=\"onLoadBody()\""
    target TAGME

6 Replies

  • Hi Igor,



    Can you wrap the code and configuration portions in [ code ] [/ code ] tags so the post is legible?



    Thanks, Aaron
  • Is the server sending compressed response payloads? If so, LTM won't decompress it before applying the stream profile. You could check the responses using a browser plugin like HttpFox for Firefox or Fiddler2. If you want to prevent server response payload compression, you can use a simple iRule:

    when HTTP_REQUEST {
       HTTP:header remove "Accept-Encoding"

    You could also use an iRule to configure the stream filter and only apply it to text responses. By default, when you use a stream profile and HTTP profile, both request and response payloads will have the stream filter applied. For examples of an iRule, you can check the STREAM::expression wiki page:

  • Right,

    As you told, stream is applied *before* the decompression. But on iRules will I got the payload uncompressed?

    If so I can let the compress working as is, and do the irule.

    Something like: (shamelessly coppied from devcentral wiki üòâ

    when HTTP_REQUEST {
        Disable the stream filter for all requests
    when HTTP_RESPONSE {
        Check if response type is text
       if {[HTTP::header value Content-Type] contains "text"}{
           Remove Body onload attribute
          STREAM::expression "@onload=\"onLoadBody()\"@@"
           Enable the stream filter for this response only

    That is it?

  • That looks good to me. You could avoid the backslash escapes by using curly braces to prevent interpretation:



    STREAM::expression {@onload="onLoadBody()"@@}



    Also, I'm referring to server response payload. LTM compression should be done to responses after the stream filter is applied (though I haven't explicitly tested this before).



  • Nice. It worked, but I have noticed that my problem was the Accept Encoding.



    I understood that stream happens BEFORE deflating. But removing the Accept-encoding header didnt I lose the compression client site? If so how can I get the best of two worlds?



    Being able to stream profile and keep compression on client side.



  • If you have compression licensed on LTM, you could enable it in a custom HTTP profile. LTM would apply the stream profile/iRule first and then compress the response content.