Forum Discussion

sys-team_172267's avatar
sys-team_172267
Icon for Nimbostratus rankNimbostratus
Sep 19, 2016

Size after compression

Hi,

I use iRule for sending Logs to external component. I want to get the size of the response after the F5 compression but unfortunately i get only the size before. i use the "content_length" header, maybe i wrong? how can i get the size after the compression?

My iRule is:

when HTTP_RESPONSE {

set pname [HTTP::header "PName"] set content_length 0 if { [HTTP::header exists "Content-Length"] } { set content_length [HTTP::header "Content-Length"] } if { [HTTP::header exists "X-AspNet-Version"] } { HTTP::header remove X-AspNet-Version }

if { [HTTP::header exists "X-Powered-By"] } {
    HTTP::header remove X-Powered-By
}

HSL::send $web_hsl "<187> Response: IP=$clientip Id=$clientport Proxy=$lb_server:$lb_port H=$Host M=$Method URL=\"$URL\" R=\"$Referer\" A=\"$Agent\" Status=[HTTP::status] Size=$content_length Time_ms=[expr {[clock clicks -milliseconds] - $http_request_time}] Number=$Number UserID=$UID Ver=$Ver pname=$pname" }

thank you, Tomer.

1 Reply

  • Hi Tomer,

     

    you may take a look to the provided iRule posted in this topic...

     

    https://devcentral.f5.com/questions/how-to-get-the-response-size-after-gzip-compression-49060?tag=irules

     

    It uses the HTTP_REQUEST event to inspect the Content-Lenght before compression and the HTTP_RESPONSE_RELEASE event to inspect the Content-Lenght after compression and performs additional math to calculate the compression rate.

     

    Note: Keep in mind, that HTTP responses with chunked HTTP content will not include a Content-Lenght header. It will be very hard to account the size for those requests... See https://en.wikipedia.org/wiki/Chunked_transfer_encoding for further information

     

    Cheers, Kai