Forum Discussion
John_Shin_10665
Nimbostratus
Aug 15, 2007x-header information logging
with [HTTP::header "target"] I am able to get the basic stuff like User-Agent. Is there separate command to grab x-header information for logging purpose?
hoolio
Cirrostratus
Aug 15, 2007You can iterate through the header names and look for a header name that starts with x- and then log the header name and value.
Here's an example:
when HTTP_REQUEST {
initializes a variable to store the headers
set headers
loop through the header names
foreach aHeader [HTTP::header names] {
check if this header starts with x-
if {[string tolower $aHeader] starts_with "x-"}{
add the header name and value to the headers variable
set headers "$headers; $aHeader: [HTTP::header value $aHeader]"
}
}
if {$headers}{
log local0. "client: [IP::client_addr]; x- headers: $headers"
}
}This assumes that there is only one instance of each header name. If you want to log multiple values of the same header name, try checking the HTTP::header page for info on HTTP::header values (Click here).
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects