HTTP responser header insert base on URI

Hi all,

how can we insert HTTP RESPONSE header base on URI? Example, if HTTP request URI contains “/test/header/”, I need to insert a new header “Via test_server” in the HTTP RESPONSE header.

Can iRule do this?

thank in advance.

Hi kky,

Sure, here is an example:

when HTTP_REQUEST { 
  
     Check if some condition in the request is true 
    if {[HTTP::path] starts_with "/test/string"}{ 
  
        Track that we want to insert a header in the response 
       set insert_response_header 1 
    } else { 
  
        Track that we do not want to insert a header in the response 
       set insert_response_header 0 
    } 
 } 
 when HTTP_RESPONSE { 
  
     Check if we're inserting a header in the response 
    if {$insert_response_header}{ 
  
        Insert the header 
       HTTP::header insert "my_header_name" "my_header_value" 
    } 
 }

Aaron

hi Aaron,

thank for your help.

it work great…