Forum Discussion
yangshuaijun_99
Nimbostratus
Sep 21, 2009According to post fields delivery the request to special pool
Hi:
I wish delivery the http request to special pool according to the post fields.
First, I collect the post data.
And then, I split the post data and capture the second field's v...
hoolio
Cirrostratus
Sep 21, 2009Hello,
That's a good start, but I'd suggest you limit the collection to 2Mb--not ~4Gb due to an issue described in SOL6578:
SOL6578: TMM will crash if an iRule collects more than 4MB of data
https://support.f5.com/kb/en-us/solutions/public/6000/500/sol6578.html
Also, you can use URI::query (Click here) to parse the payload and get the value of a parameter, if it's in the format of parameter1=value1¶mter2=value2. And then you can use switch to check the value:
when RULE_INIT {
Maximum number of bytes to collect in request
set ::max_collect_length 1024000
}
when HTTP_REQUEST {
Get the content length so we can buffer the data to process in the HTTP_RESPONSE_DATA event
if {[HTTP::header exists "Content-Length"] and [HTTP::header "Content-Length"] < $::max_collect_length}{
set content_length [HTTP::header "Content-Length"]
} else {
set content_length $::max_collect_length
}
if {$content_length > 0}{
if {$static::enc_dbg}{log local0. "$log_prefix: Collecting $content_length bytes"}
HTTP::collect $content_length
}
}
when HTTP_RESPONSE_DATA {
Get value for province parameter
set province [URI::query "?[HTTP::payload]" province]
switch $province {
"abc" {
pool my_pool_1
persist uie [HTTP::cookie "JSESSIONID"]
}
"def" {
pool my_pool_2
persist uie [HTTP::cookie "JSESSIONID"]
}
default {
pool pool_public_web_ALL
persist source_addr 30
}
}
}
You'll need to update the switch cases based on the different values you want to handle for the province parameter. And you might consider using source address persistence for a longer timeout than 30 seconds.
If you try that and it does not work, can you add debug logging and list what you've tested and what's not working?
Thanks,
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
