Forum Discussion

G__Wesley_Rober's avatar
G__Wesley_Rober
Historic F5 Account
May 27, 2005

Syntax for http header manipulation

Hi,

 

 

I’m testing http header manipulation. I’m trying to figure out the syntax of table 13.15 of the LTM Config Guide. I have the following functioning iRule:

 

 

when HTTP_REQUEST {

 

set URI [HTTP::uri]

 

if { $URI starts_with "/foo.html" } {

 

log local0.warn "URI starts with foo.html"

 

HTTP::header replace host foo.gwrf5.com

 

HTTP::uri "/foobar.html"

 

use pool foo

 

}

 

}

 

 

 

Is there some reason I can’t set the HTTP::host header in the same fashion as the HTTP::uri? When I try the rule as follows:

 

 

when HTTP_REQUEST {

 

set URI [HTTP::uri]

 

if { $URI starts_with "/foo.html" } {

 

log local0.warn "URI starts with foo.html"

 

HTTP::host “foo.gwrf5.com”

 

HTTP::uri "/foobar.html"

 

use pool foo

 

}

 

}

 

 

I get the following syntax error when saving the rule:

 

01070151:3: Rule [rewrite] error:

 

line 5: [wrong args] [HTTP::host "foo.gwrf5.com"

 

 

Also, when I try the rule as follows:

 

 

when HTTP_REQUEST {

 

set URI [HTTP::uri]

 

if { $URI starts_with "/foo.html" } {

 

log local0.warn "URI starts with foo"

 

HTTP::header host foo.gwrf5.com

 

HTTP::uri "/foobar.html"

 

use pool foo

 

}

 

}

 

 

It saves fine, but I get the following runtime error:

 

 

May 27 01:22:08 tmm tmm[4286]: 01220001:3: TCL error: Rule rewrite - Illegal argument. Illegal argument. Illegal argument. Illegal argument. Ille (line 1) invoked from within "HTTP::header host foo.gwrf5.com"

 

 

Seems to me like both of these other rules should work according to the documentation. I didn't want to dump this to support until I knew for sure what I was doing.

 

 

Thanks,

 

Wes

 

 

  • drteeth_127330's avatar
    drteeth_127330
    Historic F5 Account
    HTTP::host only returns the value of the Host header. You cannot modify it. This command is really just shorthand for
    HTTP::header host
    . I believe it largely exists for legacy reasons, i.e. for migrating 4.x rules to 9.x.