For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

MAbbas's avatar
MAbbas
Icon for Cirrus rankCirrus
Mar 21, 2022

insert HTTP Header after

Hi All

i want to insert a header a certain header 

in my scenario - i want to insert a custom header after - accept: application/json

can can someone guide -

Thanks 

 

3 Replies

  • Hi

    So something like...

    when HTTP_REQUEST {
      if { [HTTP::header "Accept"] contains "application/json" }  {
      HTTP::header insert "New-Header" "New-Header-Value"
    	}
    }
    • MAbbas's avatar
      MAbbas
      Icon for Cirrus rankCirrus

      thanks for the reply - it does insert a header - but not right after - but as the last header 

      i am trying tackel - Expect: 100-continue -- if i can insert it on F5 instead of client sending it through 

      • iaine's avatar
        iaine
        Icon for Nacreous rankNacreous

        Gotcha, how about something like...

        when HTTP_REQUEST {
        if {[HTTP::header "Accept"] contains "application/json"}{
        foreach aHeader [HTTP::header names] {
        set hValue [HTTP::header value $aHeader]
        if {$aHeader == "Accept"}{
        HTTP::header remove $aHeader
        HTTP::header insert $aHeader $hValue
        HTTP::header insert "New-Header" "New-Header-Value"
        } else {
        HTTP::header remove $aHeader
        HTTP::header insert $aHeader $hValue
        }
        }
        }
        }