Forum Discussion
Conor_Cunningha
Nimbostratus
Oct 07, 2008Replace Host on Original HTTP Request
Hi All,
I'm looking to do the following;
In the HTTP_Request, store the entire request in a variable called orgRequest
If I get a 302 redirect in the respo...
hoolio
Cirrostratus
Oct 07, 2008Hi Conor,
You could either replace the string within the HTTP::request variable:
set orgRequest [string map {oldhost.example.com newhost.example.com} [HTTP::request]]
Or you could track whether this is a retried request and then use HTTP::header replace Host "newhost.example.com":
when CLIENT_ACCEPTED {
Track whether we're retrying the request
set retrying 0
}
when HTTP_REQUEST {
Check if some condition is true, where we want to potentially retry the request
if {$some_condition}{
Check if this is a retried request
if {$retry}{
Update the Host header value
HTTP::header replace Host "newhost.example.com"
Specify a new destination for this request
node $new_ip $new_port
} else {
set orgRequest [HTTP::request]
}
}
}
when HTTP_RESPONSE {
Add logic for when to retry the request and set retry to 0 or 1
}
I assume you're not saving the full request for every request? Doing so would unnecessarily use a lot of memory.
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