Forum Discussion
Chadri_103513
Nimbostratus
Sep 01, 2009ot Payload data npassing with POST inspection
Hi,
I need some help with an iRule that is designed to inspect both GET and POST data, compare it against a data-group of accepted commands, and then redirect it to the appropriate pool...
hoolio
Cirrostratus
Sep 01, 2009Hi,
I'd be suspicious about the default of collecting 256 bytes for POST requests without a Content-Length header. Can you add logging to that portion of the rule:
...
elseif { [HTTP::method] eq "POST" } {
log local0. "[IP::client_addr]:[TCP::client_port]: POST request to [HTTP::host][HTTP::uri]\
with Content-Length: [HTTP::header Content-Length]"
if { [HTTP::header exists "Content-Length"] } {
HTTP::collect [HTTP::header Content-Length]
log local0. "[IP::client_addr]:[TCP::client_port]: Collecting [HTTP::header Content-Length] bytes"
} else {
HTTP::collect 256
log local0. "[IP::client_addr]:[TCP::client_port]: No Content-Length, collecting 256 bytes: Req: [HTTP::request]"
}
}
when HTTP_REQUEST_DATA {
log local0. "[IP::client_addr]:[TCP::client_port]: Collected [HTTP::payload length] bytes: [HTTP::payload]"
Parse the command from the request payload
set cmd [string tolower [getfield [lsearch -inline [split [HTTP::payload] "&"] command=*] = 2]]
set cmd [string tolower [URI::query "?[HTTP::payload]" command]]
if {[matchclass $::example_staging equals $cmd]} {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched $cmd, replacing host header, path and setting pool."
HTTP::header replace "Host" $exampleHost
HTTP::path $examplePath
pool $examplePool
}
}
Assuming you're parsing parameter names and values that are URL encoded in the format param1=value1¶m2=value2, you could replace this line:
set cmd [string tolower [getfield [lsearch -inline [split [HTTP::payload] "&"] command=*] = 2]]
with this line:
set cmd [string tolower [URI::query "?[HTTP::payload]" command]]
I would guess the inbuilt processing of the parameters would be faster than the list commands.
Aaron
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