Forum Discussion
DNSgeek_90802
Nimbostratus
Dec 28, 2009Get HTTP::uri in HTTP_RESPONSE
I have an irule that needs to get the URI from a 404 page and muck with it. However, when I try to reference [HTTP::uri], I get told that I cannot access it from the HTTP_RESPONSE context.
...
hoolio
Cirrostratus
Dec 28, 2009Sorry, I forgot about that part. Can you try this?
Based on the example on the HTTP::request wiki page:
http://devcentral.f5.com/wiki/default.aspx/iRules/http__retry.html
when CLIENT_ACCEPTED {
Initialize a variable to track whether a request has been retried
set retries 0
}
when HTTP_REQUEST {
Use pool A by default
pool pool_A
Check if this is a retried request
if { $retries == 0 }{
Check if request is a GET (we only save the request headers using HTTP::request)
if {[HTTP::method] eq "GET"}{
Save the request headers
set request_headers [HTTP::request]
log local0. "HTTP request headers: $request_headers"
}
} else {
This is a retry, so check if the path ends with a slash
if { [HTTP::path] ends_with "/" }{
Remove the last slash and append .html to the path
HTTP::path "[string range [HTTP::path] 0 end-1].html"
}
}
}
when LB_SELECTED {
if { $retries >= 1 }{
LB::reselect pool pool_b
}
}
when HTTP_RESPONSE {
if { [HTTP::status] == 404 }{
incr retries
log local0. "4xx error caught: retry $retries out of [active_members [LB::server pool]]"
if { $retries < [active_members [LB::server pool]] }{
HTTP::retry $request_headers
}
} else {
Successful response, reset the retries variable
set retries 0
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects