Forum Discussion

Annsar_Akhtar's avatar
Annsar_Akhtar
Icon for Nimbostratus rankNimbostratus
Feb 19, 2014

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__Harlan's avatar
    Richard__Harlan
    Historic 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"
           }
        }
    } 
    
  • Thank you very much, that works. I can see where I were went wrong along with adding an additional closing bracket.

     

    Thanks again