vADC Docs

TrafficScript to log HTTP Request and Response Headers

by aidan.clarke on ‎08-03-2014 09:36 PM - edited on ‎05-29-2015 04:20 PM by PaulWallace (1,676 Views)

Sometimes you really need to see what is happening with HTTP headers as they are passing through your SteelApp Traffic Manager.  Luckily, STM let you interact with your traffic in real time to log this info out.

 

Here is a TrafficScript that you can use to capture REQUEST and RESPONSE headers using the http.getHeaders() TrafficScript call.  Simply install the TrafficScript below, attach it to your virtual server as both a REQUEST and RESPONSE rule, and watch the logs on your STM:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$rule_state = rule.getstate(); 
   
if ($rule_state == "REQUEST"){ 
  $client_ip = request.getRemoteIP(); 
  $req_headers = http.getHeaders(); 
  
  log.info("Request received from: " . $client_ip . " with the following headers: " . lang.dump($req_headers)); 
   
if ($rule_state == "RESPONSE"){ 
  $client_ip = request.getRemoteIP(); 
  $resp_headers = http.getHeaders(); 
  
  log.info("Response received from server for request from: " . $client_ip . " with the following headers: " . lang.dump($resp_headers)); 
 

 

When you look at your log files, you will see something like this:

 

weblog640.jpg

Contributors