Forum Discussion
irule to modify the content-type response header
Hi
I have a question relating to modifying a response header for a Content-Type of Image/jpeg, the problem we have is the Content-Type Response header is being returned from the application as Content-Type: Image/jpeg and we need it to be Content-Type:image/jpeg.
I was wondering if a simple irule like the below would be the correct way to handle this as I wanting to only replace the content-type under only under /news but I have started with something simple and seeing if I could just try changing the Content-Type but I struggling to get it to work as my Irule writing is really basic:
when HTTP_RESPONSE { if { [HTTP::header exists "Content-Type" "Image/jpeg"] } { HTTP::header replace "Content-Type" "image/jpeg"
} }
Thanks in advance
2 Replies
- Richard__HarlanHistoric F5 Account
You control statement is just checking to see if the header exists not the value of the header. You can look at something like this
when HTTP_RESPONSE { if { [HTTP::header "Content-Type" ] equals "Image/jpeg" } { HTTP::header replace "Content-Type" "image/jpeg" } } } - Annsar_Akhtar
Nimbostratus
Thank you very much, that works. I can see where I were went wrong along with adding an additional closing bracket.
Thanks again
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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