Forum Discussion
domenico_strani
Nimbostratus
Apr 03, 2006Retry <request> in HTTP_RESPONSE event
Hi,
We’re testing a 3400 Big-IP in order to uderstand if its features can get our goal.
Could you please certify the iRule below on the expecially on these two main points?
1. MANAGING A RETRY: after we submit a retry of a request from the VS in order to switch pool we manage an HTTP_REQUEST event that isactivated by the retry itself.
2. TRANSFORMING A POST REQUEST IN A GET REQUEST
Assumptions:
- we have configured a Virtual Server with a VIP and 5 POOLS.
- we use an external DATA GROUP in order to catalogue the POOLS
and retrieve them dynamically.
We need to perform the following task:
1. First HTTP-Request(POST-method) management, HTTP-Header
caching and sending to default POOL.
2. HTTP-Redirect(302) catching in HTTP-Response event.
3. New HTTP-Request(GET-method) building, using previous
Request(POST) cached and overriding its method from POST to
GET.
4. HTTP-Request retrying (new HTTP-Request got) to next-POOLS
5. Applying the point 2,3 and 4 to the next-POOLs up to last POOL
using or "200 OK" code catching in Response event.
At Response-code "200-OK" or last POOL using, the HTTP-Response return to client with the standard-format.
Have you suggestions and optimizations?
Following the iRule we are using:
--------------------------------------------------------
- iRule - Partitioning ---------------------------------
--------------------------------------------------------
when CLIENT_ACCEPTED {
set defPOOL_ID "0"
set poolSep ","
set defaultPOOL [findclass $defPOOL_ID $::UMA_DG $poolSep]
set counterTAG "counter="
set counterNF "-1"
set counter 0
log local0. "COUNTER: $counter"
set qmark "?"
set checkpoint -1
log local0. "CHECKPOINT: $checkpoint"
}
when HTTP_REQUEST {
incr checkpoint
log local0. "CHECKPOINT: $checkpoint"
log local0. "METHOD: [HTTP::method]"
if {[HTTP::method] eq "GET"} {
}
if {[HTTP::method] eq "POST"} {
set contentLength [HTTP::header Content-Length]
HTTP::header remove Content-Length
set deltaPostRequest [substr [HTTP::request] 24]
log local0. "DELTA POST: $deltaPostRequest "
set baseURI [substr [HTTP::request] 5 " "]
log local0. "BASE URI: $baseURI"
HTTP::header insert Content-Length $contentLength
}
set next_pool [findclass $counter $::UMA_DG $poolSep]
log local0. "DG POOL NAME retrieved: $next_pool"
set next_pool_id $counter
log local0. "NEXT POOL ID: [incr next_pool_id]"
if { [matchclass $::UMA_DG contains $next_pool_id] } {
log local0. "Exists next-POOL"
}
else {
log local0. "Not exists next-POOL"
set strTMP [substr [HTTP::uri] 0 $counterTAG]
append strTMP $counterTAG
append strTMP $counterNF
log local0. "NEW URI REPLACED: $strTMP"
HTTP::uri $strTMP
}
log local0. "POOL USED: $next_pool"
pool $next_pool
}
when HTTP_RESPONSE {
set status [HTTP::status]
log local0. "HTTP-status: $status"
if {[HTTP::is_redirect]} {
log local0. "REDIRECT CATCHED"
incr counter
log local0. "COUNTER INCREASED: $counter"
set location [HTTP::header Location]
log local0. "HEADER LOCATION: $location"
set queryLocation [URI::query $location]
log local0. "QUERY LOCATION: $queryLocation"
set getRequest "GET "
append getRequest $baseURI
append getRequest $qmark
append getRequest $queryLocation
append getRequest $deltaPostRequest
log local0. "RETRYING REQUEST: $getRequest "
HTTP::retry $getRequest
}
else {
set counter 0
log local0. "RESET COUNTER IN RESPONSE NOT 302"
}
}
--------------------------------------------------------
2 Replies
- Colin_Walker_12Historic F5 AccountI'm not sure I understand what your specific questions are. What is it in particular you're looking to have answered here?
Colin - Graziano_RizzatHistoric F5 AccountHi Colin,
Even if the above Irule seems to work, we are looking from you guidelines and your check in order to have "sanitized" Irule to finalize it and put in production with better performance and last that what we are doing is RFC compliant.
Thnaks again for your help
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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