Forum Discussion
hooleylist
Nov 17, 2006Cirrostratus
A bit late, but...
I was trying to figure out how to insert a Content-length header in the TCP response data before TMM processed the HTTP headers. I came up with the following which seems to work:
when HTTP_REQUEST {
if it's a HEAD request, set a variable to reference in SERVER_DATA event
if { [HTTP::method]=="HEAD" }{
set request_is_head 1
log local0. "head"
}
}
when SERVER_CONNECTED {
if request was a head, collect the TCP data
if { [info exists request_is_head] and $request_is_head==1 }{
log local0. "collecting"
TCP::collect 15
}
}
when SERVER_DATA {
if request was a head, insert a content-length header with a value of 0
if { [info exists request_is_head] and $request_is_head==1 }{
log local0. "payload before: [TCP::payload]"
log local0. "index: [string first "\r\n\r\n" $server_payload]"
TCP::payload replace [string first "\r\n\r\n" [TCP::payload]] 0 "\r\nContent-length: 0"
log local0. "payload after: [TCP::payload]"
}
}
Aaron