Forum Discussion
Marc_13733
Nimbostratus
Feb 16, 2010Change Content Disposition from Inline to Attachment
Our DMS server returns only inline disposition headers:
Content-Disposition: inline; filename=somefile.pdf
We need to replace this header with the following:
Content-Disposition: attachment; filename=somefile.pdf
Basically we need something like this:
set newheader [HTTP::header Content-Disposition]
set newheader strreplace($newheader, "inline", "attachment")
HTTP::header replace Content-Disposition $newheader
Something like this??:
set newheader string map {inline attachment} [HTTP::header Content-Disposition]
- hoolio
Cirrostratus
Hi Marc,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]] } }
- Marc_13733
Nimbostratus
Thanks Aaron, works perfectly!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]] } }
- Marc_13733
Nimbostratus
Gottit!when HTTP_REQUEST { set querystring URI::query } when HTTP_RESPONSE { if { $querystring contains "attachment=1" } { HTTP::header replace Content-Disposition [string map -nocase "inline attachment" [HTTP::header Content-Disposition]] } }
- hoolio
Cirrostratus
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]] } }
- Sunil_02_141007
Nimbostratus
Can some one give me the example link which the Content-Disposition header.
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