Forum Discussion

Maria_Ramirez_5's avatar
Maria_Ramirez_5
Icon for Nimbostratus rankNimbostratus
Mar 29, 2006

FINDING A STRING IN HTTP HEADER

Hello,

 

I AM IN A HURRY:

 

 

I am not used in iRules and I have the need of creating a simple iRule. The iRule has to do the following:

 

 

We have to find the word "bid=" in the HTTP Header. If the word is found, we have to load balance traffic. If the word is not found, we do not do anything with the traffic.

 

The word "bid=" has 4 characters (letters). We have to look for it in the http header, from the 1st character, to the 800th character.

 

The problem is that we do not have very clear what is the starting string where we can start to find.

 

 

Could you provide me an example that solves this issue...A schema???

 

 

THANK YOU IN ADVANCE!!

 

 

María
  • Try this:

    
    when HTTP_REQUEST {
      HTTP::collect 800
    }
    when HTTP_REQUEST_DATA {
      if { [HTTP::payload] contains "bid=" } {
        use pool 
      } else { discard }
    }

  • Can you specify what HTTP Header the content will be in? Are you sure you don't mean that "bid=" is in the URI? If it is in the URI (ie. http://www.foo.com/somepage.cgi?bid=4&something_else).

    If it's in the URI, then something like this should work:

    when HTTP_REQUEST {
      if { [HTTP::uri] contains "bid=" } {
        pool some_pool
      } else {
        discard
      }
    }

    If it's in a named header, then you could use this

    when HTTP_REQUEST {
      if { [HTTP::header "HeaderName"] contains "bid=" } {
        pool some_pool
      } else {
        discard
      }
    }

    If your string is in the POST data for a form, then you are going to want to look in the HTTP::payload as shown in the previous post.

    -Joe