Forum Discussion
Limits with HTTP::collect
I have the following iRule, which is pretty basic and is just looking for an XML value in the payload in order to make a load-balancing decision:
when HTTP_REQUEST {
if { [HTTP::header exists Content-Length] } {
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_REQUEST_DATA {
if { [HTTP::header exists Content-Length] } {
if { [HTTP::payload] contains "CAR_DATA" } then {
pool example_pool
}
}
}
The problem with the iRule it that is doesn't seem to work. The CAR_DATA value I'm looking for is very deep into the SOAP request; roughly 240 lines into the request but the content-length on the request is only about 150K. The pool example_pool exists--do I need to declare it in the iRule if it isn't the default pool listed in the VIP? I'm puzzled why this rule wouldn't work. Requests are coming over http.
- mahnsc
Nimbostratus
Sorry. One additional comment/question: Is there a limit to how far into the payload an iRule will look for a value?
- Kevin_Stewart
Employee
HTTP::collect should store as much data as you tell it to.
I guess maybe the first question would be, is this content in every request from the client? Are there HTTP requests from this client before the XML data is sent?
Can you insert a log statement into the HTTP_REQUEST_DATA event to see if it is at least seeing the content?
- mahnsc
Nimbostratus
I can add that. I'm trying to debug it. Should I create a variable to store the payload so I can log it?
- Kevin_Stewart
Employee
Syslog will only capture around the first 1K of data by default, so probably not worth trying to dump the entire XML contents to the screen.
A simple log statement is sufficient here just to see if the string match is successful:
log local0. "found it"
I just tested this with a 32K file with the matching contents further down in the file (~line 800) and it was able to find it.
- mahnsc
Nimbostratus
OK. I'll give it a try. To answer your other question, I do not believe so. The developers gave me some standalone tests that I can execute--the one test contains the data, the other test does not but both are valid transactions.
- PeteWhite
Employee
Content-Length and data length should be exactly the same.
It is good practise to check the size of Content-Length and use a default size if the Content-Length is too large or if it is not present. When you use HTTP::collect you should specify the size for it to retrieve and this will become the size of the buffer for HTTP::payload.
- mahnsc
Nimbostratus
After adding the logging, I was able to determine that the iRule was working as expected with the test cases that the developers had provided and no action was necessary. I'm not sure what the developers were seeing that gave them the indication that it wasn't working. Thanks to all for your responses.
Recent Discussions
Related Content
* 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