Amazing thing in iRules, you can submit to the original factory that this is a bug to be optimized or that iRules has a strange bug with "{" or "}" in the HTTP header
It may also be a disadvantage of the TCL language. Lists can be represented by "" or {}, which can sometimes be ambiguous, unlike Python lists, which can only be represented by []
Some manufacturers' load balancing scripts use lua language instead of tcl
I found that as long as the name field in the HTTP header contains { or }, HTTP:: header remove will report an error,
It seems that HTTP:: header remove name, name value refers to the value in HTTP:: header names storage format, rather than the value of variable string that we usually understand
log local0. "names is: [HTTP::header names]" the log result is:
names is: Host User-Agent Accept {{esbsoapheader}userName} Connection {{esbsoapheader}userName}
HTTP header name {esbsoapheader}userName the storage format in [HTTP::header names] is {{esbsoapheader}userName}
so, we need to use this format HTTP::header remove {{{esbsoapheader}userName}} or
HTTP::header remove "{{esbsoapheader}userName}"
use HTTP::header remove {{esbsoapheader}userName} will raise error!
if we HTTP::header insert "\{esbsoapheaderuserName" "f5-gtm"
the [HTTP::header names] running result is:
names is: Host User-Agent Accept \{esbsoapheaderuserName Connection
we need to this format to remove:
HTTP::header remove {\{esbsoapheaderuserName}
It seems that in the list of tcl, the element storage that contains { or } needs to carry {}
(bin) 49 % set a {Host User-Agent Accept {esbsoapheader}userName Connection}
Host User-Agent Accept {esbsoapheader}userName Connection
(bin) 50 % lindex $a 3
list element in braces followed by "userName" instead of space
(bin) 51 % string length $a
57
(bin) 53 % set a "Host User-Agent Accept {esbsoapheader}userName Connection"
Host User-Agent Accept {esbsoapheader}userName Connection
(bin) 55 % lindex $a 1
list element in braces followed by "userName" instead of space
(bin) 56 %
(bin) 57 % set a {Host User-Agent Accept {{esbsoapheader}userName} Connection}
Host User-Agent Accept {{esbsoapheader}userName} Connection
(bin) 62 % lindex $a 3
{esbsoapheader}userName
(bin) 63 % set qq "Host User-Agent Accept {{esbsoapheader}userName} Connection"
Host User-Agent Accept {{esbsoapheader}userName} Connection
(bin) 64 % lindex $qq 3
{esbsoapheader}userName
(bin) 65 %
(bin) 95 % set names_list {Host User-Agent Accept \{esbsoapheader\}userName Connection}
Host User-Agent Accept \{esbsoapheader\}userName Connection
(bin) 97 % lindex $names_list 3
{esbsoapheader}userName
(bin) 98 %
(bin) 70 % set names "Host User-Agent Accept \\{esbsoapheader\\}userName Connection"
Host User-Agent Accept \{esbsoapheader\}userName Connection
(bin) 71 % lindex $names 3
{esbsoapheader}userName
when HTTP_REQUEST {
if { [HTTP::uri] eq "/demo2" } {
HTTP::header insert "\{esbsoapheaderuserName" "spencer"
HTTP::header insert Connection close
HTTP::header insert "{esbsoapheader}userName" "f5-bigip"
foreach aHeader [HTTP::header names] {
log local0. "HTTP Request Headers: $aHeader: [HTTP::header value $aHeader]"
}
log local0. "exists header: [HTTP::header exists "{esbsoapheader}userName"]; value is [HTTP::header "{esbsoapheader}userName"]"
log local0. "names is: [HTTP::header names]"
log local0. "***************REMOVING BAD HEADER************"
# set a "{esbsoapheader}userName"
# HTTP::header remove [list $a]
# HTTP::header remove "{{esbsoapheader}userName}" it also works correct
HTTP::header remove {{{esbsoapheader}userName}}
HTTP::header remove {\{esbsoapheaderuserName}
foreach aHeader [HTTP::header names] {
log local0. "HTTP Request Headers: $aHeader: [HTTP::header value $aHeader]"
}
}
}