How 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::header insert, puts it at the. Since there are no commands to insert it into a specific spot, I figure I need to create a variable with each HTTP::header name=value pair and then delete them all, then start adding one by one starting with my custom one.
Either way, I have been trying foreach loops and while loops and can't figure out how to use a dynamic variable that increments as I iterate through the number of inbound HTTP headers. I'm currently trying something like this:
set y 0
set hc [HTTP::header count]
while {$y <= $hc} {
log local0. "y=$y"
set v "v-$y"
log local0. "v=$v"
set na "[HTTP::header at $y]"
set va "[HTTP::header value $na]"
log local0. "na=$na va=$va"
set $v "$na $va"
log local0. "v=$v"
incr y
}
I'm sure I'm missing some tcl savvy so I'll take any suggestions you have.