Forum Discussion
Capturing HTTP Header Info
Depends on what you want to get and use the header data for. You could use an iRule to capture the headers from the server response, for example:
when HTTP_RESPONSE {
  foreach hdr [HTTP::header names] {
    log local0. "HTTP Header : $hdr = [HTTP::header values $hdr]"
    }
}
will produce log lines in /var/log/ltm, similar like this:
Mar 25 22:18:19 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : Content-Length = 1293
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : Content-Type = text/html
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : Content-Encoding = gzip
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : Last-Modified = {Fri, 10 Feb 2012 06:48:40 GMT}
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : Accept-Ranges = bytes
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : ETag = {"094905c0e7cc1:0"}
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : Vary = Accept-Encoding
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : Server = Microsoft-IIS/7.0
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : X-Powered-By = ASP.NET
Mar 25 22:18:40 apmlab1 info tmm1[11675]: Rule /timo/test_hdr_iRule : HTTP Header : Date = {Wed, 25 Mar 2015 20:18:40 GMT}
This is just for reference, so modify to suit your needs and attach your iRule to your virtual server as a resource in addition to the server pool.
Note that the foreach -loop will produce multiple occurrences of same log line if there are multiple occurrences of the same header name. HTTP::header values -command will list all values of the same header name in this case.
Recent Discussions
Related Content
* 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