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

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

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

Thank you both.

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