Forum Discussion

Jonathan_Landis's avatar
Jonathan_Landis
Icon for Nimbostratus rankNimbostratus
Feb 09, 2006

Multiple message-header fields with the same field-name

The following rule logs the "Cookie" header of http requests:

 

 

when HTTP_REQUEST {

 

set ch [HTTP::header "Cookie"]

 

if {$ch != ""} {log local0. "$ch"} else {log local0. "no cookie"}

 

}

 

 

If there are multiple cookie headers, it returns the last one. Is this a bug or a feature?

4 Replies

  • The HTTP::header command will, as you found out, pull the last header with the given name.

     

     

    You might want to take a look at the HTTP::cookie command for accessing cookies

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/HTTP__cookie.html

     

    Click here

     

     

    -Joe
  • Thanks, Joe! Sometimes there are multiple "Accept" headers as well. Is there a way to collect all of them?
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    According to RFC 2616 there should be one Accept header, with a list of the acceptable data types in it. Click here

     

     

    This can be split up into seperate variables as needed with the list commands native to TCL once you pull the header value itself.

     

     

    -Colin
  • The RFC does not say there should be only one "Accept" header. See the last paragraph in section 4.2.