Forum Discussion
5 Replies
- VernonWellsEmployee
The error very likely arises from the lack of spaces in the source code. You have this:
when HTTP_REQUEST { if{[HTTP::uri] contains"http://www.abc.com"}{
At a minimum, you need a space between if and the open brace, as well as between contains and the following quote ("):
if {[HTTP::uri] contains "http://www.abc.com"}{
or the parser will fail.
As also pointed out above, though, there are a few logic errors. Those won't cause a syntax error, but they will mean your code won't do what you want.
When a person types "; in his browser, the user-agent generates an HTTP Request message. That message will look something like this:
GET / HTTP/1.1 Host: www.abc.com User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive
That first line (the one beginning with "GET") is the Start-Line. It is structured as follows:
HTTP::uri retrieves the part. Notice that HTTP::uri specifically does NOT return the URI entered into the user-agent. See the "Elaboration" section in this article for more details:
HTTP::host (a short-hand for HTTP::header value Host) retrieves the "Host" header, which is not embedded in the (and hence, not returned as part of HTTP::uri).
As that iRule recipe also explains, in general, when using HTTP::host, it makes sense to wrap it in string tolower, just as
@Jinshudoes. - John_Heyer_1508Cirrostratus
Not sure what you mean by "if client browser". But I think you want something like this?
if { [HTTP::host] eq "" } { pool test_pool } else { reject }
- yuanqiang_22112Nimbostratus
@John Heyer , you are right,3Q