29-Oct-2012 04:55
Hi,
I have a problem in the following case:
On a website there is a css-file that sometimes is not completely transferred to the client in the response. Now I like to write an iRule, that logs the length of this file when it is transferred to the client in server response, but I do not really know how to get _only_ information about this file in HTTP_RESPONSE event.
The request is a GET for /a/b/main.css
Regards,
Sören
29-Oct-2012 05:15
You can set a variable on the request, only when you see this URL and then you should be able to read the value of the HTTP Content-Length header in any response, only if the variable has been set. Does that make sense?
29-Oct-2012 05:17
29-Oct-2012 05:19
Hi,
yes - I know. I wrote an iRule in my first try like this:
when HTTP_REQUEST {
if { [HTTP::uri] eq "/a/b/main.css" }
log local0. "CSS-DEBUG: [HTTP::uri]"
}
}
when HTTP_RESPONSE {
if { [HTTP::header "Content-type"] eq "text/css" }{
log local0. "CSS-DEBUG: Content-Length is [HTTP::header Content-Length]"
}
}
The log shows me now all Content-Length values for all css-Files delivered to the clients (there is more than one css-File on the site). How can I only log the contend length from the main.css ?
29-Oct-2012 05:39
when HTTP_REQUEST {
set uri [HTTP::uri]
}
when HTTP_RESPONSE {
if { $uri equals "/a/b/main.css" } {
log local0. "CSS-DEBUG: Content-Length is [HTTP::header Content-Length]"
}
}
29-Oct-2012 06:14
Hi,
thanks - It works. I never thought that it can be so easy 🙂
Regards,
Sören
29-Oct-2012 10:32
when HTTP_REQUEST {
if { [HTTP::uri] equals "/a/b/main.css" } {
set log_cl 1
} else {
set log_cl 0
}
}
when HTTP_RESPONSE {
if {$log_cl}{
log local0. "CSS-DEBUG: Content-Length is [HTTP::header Content-Length]"
}
}
Aaron