Forum Discussion

keving9012_2467's avatar
keving9012_2467
Icon for Nimbostratus rankNimbostratus
Jan 29, 2016

Issue with iRule for Stream of Chunked responses.

Hello, we're having an issue with an iRule that we have in place with the streaming of chunked responses. On certain pages of our site it causes there to be a connection issue. This is the rule currently. We've tried using the HTTP::collect method but that causes all characters to be rendered improperly, letters with accent's over top get garbled.

when RULE_INIT {
    set static::debug_iRule-na_Generic-httpS_response_replace_443 1
}

when HTTP_REQUEST {
    set request_uri [HTTP::uri]
    set client_ipaddr [IP::client_addr]
    HTTP::header remove Accept-Encoding
    STREAM::disable
}

when HTTP_RESPONSE {
    set vs_port [TCP::local_port]

    if {[HTTP::header value Content-Type] contains "text/html"}{  

        STREAM::expression {@http://.*?:[0-9]+/@@}

        STREAM::enable  
   } else {
        STREAM::disable
   }
}

when STREAM_MATCHED {
    set replace_string ""
    set matched_text [STREAM::match]
    regsub -all {http://(.*)?:[0-9]+/} $matched_text {https://\1:443/} replace_string
    regsub -all {http://(.*)?/} $replace_string {https://\1/} replace_string
    if {${static::debug_iRule-na_Generic-httpS_response_replace_443}} {log local0.debug "\[--debug--\] VS_NAME=\[[virtual name]\]: source_string=\[$matched_text\] replacement_string=\[$replace_string\]"} 
    STREAM::replace $replace_string
}

Any information or suggestions are very appreciated.

1 Reply

  • Hi keving9012,

    I've had some issues with STREAM and chunking in the past. The snippet below has help in my case. You may give it a try...

    when HTTP_RESPONSE {
        if [HTTP::header exists "Transfer-encoding"] {
            HTTP::payload rechunk
        }
    }
    

    Cheers, Kai