Forum Discussion
Frank_J_104756
Oct 31, 2007Historic F5 Account
HTTP::payload replace
I have 2 needs...1 to replace/hide the server in the http redirects that are being sent by the node. 2) to replace/hide the server in the actual content.
when HTTP_RESPONSE {
if { [LB::server addr] eq "10.1.1.1" } {
HTTP::header replace Location [string map { } [HTTP::header Location]] }
elseif { [LB::server addr] eq "10.1.1.2" } {
HTTP::header replace Location [string map { } } [HTTP::header Location]] }
}
the irule above works great for the redirects but not for the content / payload. When I read up on the HTTP::payload command though it's specifying offset or begin point and I won't know that because the servername will appear different on different pages.
Any suggestions ? I'd love to do a HTTP::payload replace with a findstr if possible but they way I read the wiki for HTTP::payload replace I can't.
Oh, and by the way, using stream profile isn't working. I have a separate support case open for that. I would have preferred to use stream but for some reason it ain't working whereas the irules are.
thanks!!!
- hoolio
Cirrostratus
There is an example showing how to replace a string in a payload on the HTTP::payload page (Click here) which uses regsub -all. I suppose you could use string map for a more efficient replacement if don't need a regex to describe the search string(s).when HTTP_RESPONSE { if { [HTTP::header exists "Content-Length"] } { set content_length [HTTP::header "Content-Length"] } else { set content_length 1000000 } if { $content_length > 0 } { HTTP::collect $content_length } } when HTTP_RESPONSE_DATA { regsub -all "oursite" [HTTP::payload] "oursitedev" newdata log "Replacing payload with new data." HTTP::payload replace 0 $content_length [string map {oursite oursitedev} [HTTP::payload]}] HTTP::release }
- Frank_J_104756Historic F5 Accountthey're running 9.4.1 HF1...let me try your solution, Thanks by the way!!!...I'll post back if it works...I do have a support case open on the stream profile..so far the feedback I've gotten after they checked the tcpdumps, qkview, and httpwatch captures is the stream profile should have worked and it's being escalated to see why it isn't...
- Frank_J_104756Historic F5 Accountso irule now looks like
- hoolio
Cirrostratus
From the wiki page and Deb's post (Click here), it looks like you need to use the original content length (what's been collected so far). LTM should then recalculate the new length and update the Content-Length header it sends (in 9.4.0 and later). - Frank_J_104756Historic F5 AccountI think I'm getting the out of bounds because there is no content length set w/in the original http header...so the irule is using 10000 when the content may only be 100,200, etc...
- hoolio
Cirrostratus
Ah. Can you try this then? - Frank_J_104756Historic F5 AccountI get wrong of args for those lines when I do that..
- hoolio
Cirrostratus
There should be '[HTTP::payload length]' after the 0. Also, I think nwte1jas7 should be nwteljas6 is the second HTTP::payload replace command. - Frank_J_104756Historic F5 AccountAaron, I'm not getting errors anymore but it appears like none of the HTTP_RESPONSE_DATA section is even running. I put a log entry at the beginning of it to see if I got anything and I didn't. Here's what I have in teh irule now...
- hoolio
Cirrostratus
It looks like you removed the HTTP::collect command from the HTTP_RESPONSE event. This is what dictates that LTM should buffer the HTTP data in the response. The HTTP_RESPONSE_DATA event is triggered when the amount of data specified in the HTTP::collect command has been collected.
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