Aj2
Jan 08, 2024Altostratus
Need Help in iRule to Modify HTTP header parameter.
I need to Write iRule where I want to change the HTTP header parameter from
- sname to Sname
- 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
}