Forum Discussion
jay_41157
Nimbostratus
Apr 21, 2011HTTP::PAYLOAD
HI,
I am trying to replace the page content with x's however I am running into some issues and not sure what to do..
Please help.
here is the error i see in the ltm log file:
Apr 21 16:28:16 local/tmm err tmm[4788]: 01220001:3: TCL error: parse_test_irule - Out of bounds (line 2) invoked from within "HTTP::payload replace 0 $content_length [string repeat "X" $content_length]"
Apr 21 16:28:53 local/tmm1 err tmm1[4789]: 01220001:3: TCL error: parse_test_irule - Out of bounds (line 6) invoked from within "HTTP::payload replace 0 $content_length [string repeat "X" $content_length]"
Apr 21 16:29:26 local/tmm err tmm[4788]: 01220001:3: TCL error: parse_test_irule - Out of bounds (line 2) invoked from within "HTTP::payload replace 0 $content_length [string repeat "X" $content_length]"
Here is what my irule looks like, I got it from the WIKI page examples...
when HTTP_RESPONSE {
Only check responses that are a text content type (text/html, text/xml, text/plain, etc).
if { [HTTP::header "Content-Type"] starts_with "text/" } {
Get the content length so we can collect the data (to be processed in the HTTP_RESPONSE_DATA event)
Limit collection to 1Mb (1048576 minus a little to spare) - See SOL6578 for details
if { [HTTP::header exists "Content-Length"] } {
if { [HTTP::header "Content-Length"] > 1048000 }{
Content-Length over 1Mb so collect 1Mb
set content_length 1048000
} else {
Content-Length under 1Mb so collect actual length
set content_length [HTTP::header "Content-Length"]
}
} else {
Response did not have Content-Length header, so use default of 1Mb
set content_length 1048000
}
Don't collect content if Content-Length header value was 0
if { $content_length > 0 } {
HTTP::collect $content_length
}
log local0. "Payload Length:[HTTP::payload length]:"
log local0. "Content Length:[HTTP::header value Content-Length]:"
log local0. "Payload:[HTTP::payload]:"
}
}
when HTTP_RESPONSE_DATA {
log "Replacing payload with new data."
HTTP::payload replace 0 $content_length [string repeat "X" $content_length]
[HTTP::release]
}
Thanks,
Jay
- nitass
Employee
what software version r u running? does the error always happen or sometime? do u know if server sends chunked response? - jay_41157
Nimbostratus
version 10.2 HF2; not sure if the server sends chunked response... the vip has response chunking enabled using a profile. - hoolio
Cirrostratus
You could prevent chunking on server responses (which will break the iRule as no content-length header is set) by setting the HTTP version in the request to 1.0:Poached from http://devcentral.f5.com/wiki/default.aspx/iRules/CreditCardScrubber.html when HTTP_REQUEST { Prevent the server from sending a compressed response remove the compression offerings from the client HTTP::header remove "Accept-Encoding" Don't allow response data to be chunked if { [HTTP::version] eq "1.1" } { Force downgrade to HTTP 1.0, but still allow keep-alive connections. Since HTTP 1.1 is keep-alive by default, and 1.0 isn't, we need make sure the headers reflect the keep-alive status. Check if this is a keep alive connection if { [HTTP::header is_keepalive] } { Replace the connection header value with "Keep-Alive" HTTP::header replace "Connection" "Keep-Alive" } Set server side request version to 1.0 This forces the server to respond without chunking HTTP::version "1.0" } }
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