Skipping Large Content Size for HTTP Collect?
in aFleX
Posted by TODDH
How would I add an if / else to check for HTTP content-length and only perform collect when the size is smaller than 1MB / 1.2MB?
when HTTP_RESPONSE {
HTTP::collect
}
when HTTP_RESPONSE_DATA {
set clen [HTTP::payload length]
regsub -all "elm" [HTTP::payload] "elm" secureurls
HTTP::payload replace 0 $clen $secureurls
}
How would I add an if / else to check for HTTP content-length and only perform collect when the size is smaller than 1MB / 1.2MB?
when HTTP_RESPONSE {
HTTP::collect
}
when HTTP_RESPONSE_DATA {
set clen [HTTP::payload length]
regsub -all "elm" [HTTP::payload] "elm" secureurls
HTTP::payload replace 0 $clen $secureurls
}
0
Comments
Hi Todd,
From what I understand you have:
- a VIP doing SSL offload (clients talks on HTTPS to the VIP and the AX talks on HTTP to the servers)
- absolute links in some pages (with for instance "http: //www.example.com/xyz" and you have to rewrite them to "https://www.example.com/xyz"
and you don't want to look for absolute links in all objects such as big PDF objects for instanceSo if I understand your need correctly, here is what you could do:
Absolute links could be in html, css, etc but all these are "text" based objects type => configure your aFleX to apply only on these type of objects (absolute links won't be in images, ppt, etc for instance).
You don't have to specify how much you want the AX to collect, since you want to collect the whole response. When you don't specify how many bytes you want AX to collect, the AX will simply collect the whole object and this whatever if the response is sent with "Content-Length" information or in "Chunked" mode.
Note: AX will collect up to 1.25MB objects. If the object is bigger (very unlikely) then AX will stop collecting the data after 1.25MB and won't be able to rewrite any absolute link if there are after the 1.25MB.
How you aFleX will look like?
when HTTP_REQUEST { if { [HTTP::header "Content-Type"] starts_with "text" } { HTTP::header remove Accept-Encoding } } when HTTP_RESPONSE { if { [HTTP::header "Content-Type"] starts_with "text" } { HTTP::collect } } when HTTP_RESPONSE_DATA { if { [HTTP::header "Content-Type"] contains "text" } { set payload_length [HTTP::payload length] regsub -all "http://intranet.abc.com" [HTTP::payload] "https://intranet.abc.com" new_payload HTTP::payload replace 0 $payload_length $new_payload HTTP::release } }
Important Note:
You can see I removed the "Accept-Encoding" from the request.
aFleX won't try to decompress the response. So if the server replies with the object compression, the aFleX will never be able to detect the absolute link and rewrite it.
Removing the "Accept-Encoding" from the request will force the server to reply without compression, even if HTTP compression is enabled on your servers.
BTW you could configure the AX to do the HTTP compression in an HTTP template (and off loading the servers from doing it too)
Last Note: I assume your AX release is newer than 2.4.2P2. We've done some enhancements on HTTP:Collect. If you have older release, please upgrade first as what I explain above is not correct on older releases.