For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Aj2's avatar
Aj2
Icon for Altostratus rankAltostratus
Jan 08, 2024
Solved

Need Help in iRule to Modify HTTP header parameter.

I need to Write iRule where I want to change the HTTP header parameter from

  1. sname to Sname
  2. uaccount to Uaccount
HTTP Header
POST /URI PATH/ HTTP/1.1\r\n
sname : BEVI9999\r\n
uaccount : \r\n
\r\n


is it correct iRule

when HTTP_REQUEST {
  HTTP::header replace sname SName
  HTTP::header replace uaccount UAccount
}

expected output

HTTP Header
POST /URI PATH/ HTTP/1.1\r\n
SName: BEVI9999\r\n
UAccount: \r\n
\r\n

Above iRule is correct for the requirement?

  • HTTP headers are not case sensitve in correctly implemented HTTP servers (see https://www.rfc-editor.org/rfc/rfc9110.html#name-field-names) , so the BIG-IP iRule command to handle them is also case insensitive (https://clouddocs.f5.com/api/irules/HTTP__header.html).

    You'll have to first grab the header names (with any case), delete the headers (with any case), then re-add new headers (with your desired case). Something like this should work:

    when HTTP_REQUEST {
    set sname [HTTP::header value sname]
    set uaccount [HTTP::header value uaccount]

    HTTP::header remove sname
    HTTP::header remove uaccount

    HTTP::header replace SName $sname
    HTTP::header replace UAccount $uaccount
    }

     

2 Replies