Forum Discussion

Baqar_Husain_81's avatar
Baqar_Husain_81
Icon for Nimbostratus rankNimbostratus
Feb 05, 2008

action if http::header host exists

Simple enough question, and I'm drawing a blank and can't find anything relevant in the wiki or the forums:

 

Just looking for the correct syntax ..

 

 

if exists Host then replace HTTP::host with my.xyz.com

 

else

 

insert HTTP::header Host your.xyz.com

 

 

I'm converting HTTP/1.0 requests to HTTP/1.1 ... that part is working fine, but I want the LTM to insert an HTTP HOST entry should the original 1.0 request not have it.

 

 

Thanks

5 Replies

  • Something like this?

    
    when HTTP_REQUEST {
       if {[string length [HTTP::header value Host]]}{
          HTTP::header replace Host my.xyz.com
       } else {
          HTTP::header replace Host your.xyz.com
       }
    }

    Aaron
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Why not just use the "HTTP::header exists" command?

    when HTTP_REQUEST {
       if {[HTTP::header exists Host]}{
          HTTP::header replace Host my.xyz.com
       } else {
          HTTP::header replace Host your.xyz.com
       }
    }

    ???

    /deb
  • would the HTTP::header replace Host your.xyz.com work if the Host statement doesn't exist?
  • The wiki page for HTTP::header (Click here) indicates that if the header doesn't exist already, it will be inserted, so Deb's example should work perfectly.

     

     

    Aaron