when HTTP_RESPONSE {
Check if there is a Content-Disposition header with inline in the value
if {[string tolower [HTTP::header Content-Disposition]] contains "inline"}{
Replace the Content-Disposition header with inline replaced with attachment
HTTP::header replace Content-Disposition [string map -nocase "inline attachment" [HTTP::header Content-Disposition]]
}
}
One more thing - we want this modification to only occur when the querystring contains the word “attachment”. When we do this:
when HTTP_RESPONSE {
set querystring URI::query
if { $querystring contains "attachment=1" } {
HTTP::header replace Content-Disposition [string map -nocase "inline attachment" [HTTP::header Content-Disposition]]
}
}
We get an error “command is not valid in current event context”. Apparently we can’t query the querystring in a HTTP_RESPONSE block. How else can we do this header modification based on the URI?
Great that you figured it out. You could also try something like this:
when HTTP_REQUEST {
Check if the query string contains a parameter named attachment with a value of 1
if {[URI::query [HTTP::uri] "attachment"] == 1}{
set check_response 1
} else {
set check_response 0
}
}
when HTTP_RESPONSE {
if { $check_response } {
HTTP::header replace Content-Disposition [string map -nocase "inline attachment" [HTTP::header Content-Disposition]]
}
}