HEADER INSERT iRule

Hi Guys,

I’m new to the topic of iRules and would like some help with writing up an iRule that can do the following:

F5 LTM should insert header as follows:

-- F5 checks to see if a “origin-scheme” header exists

-- -- If it already exists for any reason, it will remove it and re-insert its own.

-- -- If it does not exist, it will insert one.

-- “origin-scheme” header is inserted with a value of “http” or “https” depending on how traffic comes to F5 (port 80 or 443)

*I would greatly appreciate any help/guidance!!!

Something like this:

when HTTP_REQUEST {
     if { [HTTP::header exists "origin-scheme" } {
          HTTP::header remove "origin-scheme"
     }
     HTTP::header insert "origin-scheme" "my-value"
}