For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

iRule Feature Highlight HTTP::is-redirect

I recently helped optimize an iRule intended to manipulate server-set redirects and was re-acquainted with a handy iRules command:  HTTP::is_redirect .

It's a Boolean command that tests for HTTP redirect response codes and returns 1 for a match, 0 for no match.

A fairly common practice seems to be to use the HTTP::status command to retrieve the HTTP response status code, then compare it to a list of possible HTTP redirect response status values.  However, since not all 3xx responses are redirects, it's not enough to check if the status begins with a "3".  Instead, the HTTP status code must be compared to a list of possible values (rather than a single value) in order to capture only the desired responses.  Therefore, in most cases it will be more optimal and more accurate to use the HTTP::is_redirect command instead of the HTTP::status command. 

The following response codes cause HTTP::is_redirect to return a match (and all include a Location header directing the browser to an alternate resource):

  • 301 (Moved Permanently)
  • 302 (Found)
  • 303 (See Other)
  • 305 (Use Proxy)
  • 307 (Temporary Redirect)
Published May 20, 2008
Version 1.0

1 Comment