Forum Discussion
James_Thomson
Employee
Feb 02, 2015How can I reorder HTTP headers?
I want to insert an HTTP header into the current list of HTTP headers, but I need it to be the first HTTP header in the list, before the Host, Content-Type and Content-Length. Using the standard HTTP...
StephanManthey
Nacreous
Feb 02, 2015Hi James,
how about reading all header into an array, delete them, reorder and reinsert?
Here is some sample code used to remove a specific cookie parameter out of response cookies.
It needs to be rewritten to get fired in HTTP_REQUEST (you did not specify), get a list of all headers, delete them, insert the new one followed by all stored parameters.
when HTTP_RESPONSE {
if {[HTTP::header exists "Set-Cookie"]}{
array set cookielist { }
foreach cookievalue [HTTP::header values "Set-Cookie"] {
set cookielist([getfield $cookievalue "=" 1]) [string map -nocase { "; HttpOnly" ""} $cookievalue]
log local0. "serverside cookie: $cookievalue"
}
HTTP::header remove Set-Cookie
foreach cookiename [array names cookielist] {
if { [info exists cookielist($cookiename)] } {
log local0. "clientside cookie: $cookielist($cookiename)"
HTTP::header insert Set-Cookie $cookielist($cookiename)
}
}
}
}
Thanks, Stephan
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects