Forum Discussion
Mar 28, 2006
I'd just use the TCL builtin "string range" command to extract the content you want from the original referrer (you can specify a start index and end of string for the stopping point). Something like this should do the job:
when HTTP_REQUEST {
set referer [HTTP::header "Referer"]
if { $referer starts_with "https://" } {
log local0. "Found Referer header: $referer"
set newReferer "http://[string range $referer 8 end]"
log local0. "Changing Referer header to $newReferer"
HTTP::header replace "Referer" $newReferer
}
}
I don't think you need to call the "header exists" command as the assignment into the referer will be empty if the header doesn't exist and then fail the next "starts_with" comparison.
If this still doesn't work, you might try removing the Referer header and then inserting the new one with the "HTTP::header remove" and "HTTP::header insert" commands. That should be equivalent to the "HTTP::header replace" command though...
-Joe