Forum Discussion
MonkeyWrench_10
Aug 31, 2011Nimbostratus
How to inspect POST data on HTTP_REQUEST
Hi, I'm trying to route users based on the payload of a POST request, and failing :) Here's a simplified version of my iRule: when HTTP_REQUEST { HTTP::co...
hooleylist
Aug 31, 2011Cirrostratus
HTTP::payload should normally return any payload bytes received in the first packet containing the HTTP headers.
Regardless to guarantee collection of the full HTTP payload, you need to call HTTP::collect. Make sure to limit collect to less than 4Mb to avoid a TMM crash:
From http://devcentral.f5.com/wiki/iRules.http__collect.ashx
when HTTP_REQUEST {
if {[HTTP::method] eq "POST"}{
Trigger collection for up to 1MB of data
if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576}{
set content_length [HTTP::header "Content-Length"]
} else {
set content_length 1048576
}
Check if $content_length is not set to 0
if { content_length > 0} {
HTTP::collect $content_length
}
}
}
when HTTP_REQUEST_DATA {
do stuff with the payload
set payload [HTTP::payload]
}
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