Forum Discussion
tarsier_90410
Oct 17, 2011Nimbostratus
HTTP::respond - bug or improper use?
When using HTTP::respond 302 Location "https://<...>" in the HTTP_RESPONSE when the server also issued a 302, the LTM's 302 does not appear to work and the client receives the location specified by the server.
Shouldn't the use of HTTP::respond cause the server response to be discarded? When I do something similar with HTTP::respond 200, the entire server response appears to be dropped.
- Michael_YatesNimbostratusHi tarsier,
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/redirect" } { HTTP::respond 302 Location "http://google.com" } }
- tarsier_90410NimbostratusThe significant difference is that I am doing the redirect in the HTTP_RESPONSE event, and also setting cookies, for a server response that sets a particular header...
when HTTP_RESPONSE { if { [HTTP::header exists "status"] } { switch [HTTP::header value "status"] { "OK" { HTTP::respond 302 Location "https://$HOSTNAME$URI" "Set-Cookie" $MY_COOKIE return } ... other cases ... default { } } } }
- Michael_YatesNimbostratusLOL. I got a good laugh out of that. No wonder it worked so well 🙂
when HTTP_REQUEST { set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" log local0. "=============================================" log local0. "$LogString (request)" foreach aHeader [HTTP::header names] { log local0. "$aHeader: [HTTP::header value $aHeader]" } log local0. "=============================================" } when HTTP_RESPONSE { log local0. "=============================================" foreach aHeader [HTTP::header names] { log local0. "$aHeader: [HTTP::header value $aHeader]" } log local0. "=============================================" http://devcentral.f5.com/wiki/iRules.LogHttpHeaders.ashx }
- tarsier_90410NimbostratusSorry for the confusion, but the "status" header is being inserted by our java developers in the app, and I am not confusing it with the HTTP status. We could make it any name but "status" is what they chose. I can see the "OK" branch of the switch block is executing if I add a log statement, it's just that the HTTP::respond appears to have no effect.
- Michael_YatesNimbostratusInteresting.
when HTTP_RESPONSE { if { [string tolower [HTTP::header exists "server" ]] } { switch [string tolower [HTTP::header value "server" ]] { "microsoft-iis/6.0" { HTTP::respond 302 Location "https://www.google.com" } } } }
- nitassEmployeeit seemed working fine in my lab. is there anything i missed?
[root@iris:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.17.33:http ip protocol tcp rules myrule profiles { http {} tcp {} } } [root@iris:Active] config b pool foo list pool foo { members 10.10.70.110:http {} } [root@iris:Active] config b rule myrule list rule myrule { when HTTP_RESPONSE { if {[HTTP::header exists "status"]} { switch [HTTP::header value "status"] { "OK" { HTTP::respond 302 Location "http://www.google.com" "Set-Cookie" "test" } default { do something } } } } } [root@iris:Active] config curl -I http://10.10.70.110 HTTP/1.1 200 OK Date: Tue, 18 Oct 2011 00:10:01 GMT Server: Apache/2.0.59 (rPath) Last-Modified: Sat, 11 Jun 2011 00:31:47 GMT ETag: "667a-67-cfb682c0" Accept-Ranges: bytes Content-Length: 103 Vary: Accept-Encoding status: OK Content-Type: text/html; charset=UTF-8 [root@iris:Active] config curl -I http://172.28.17.33 HTTP/1.0 302 Found Location: http://www.google.com Set-Cookie: test Server: BigIP Connection: Keep-Alive Content-Length: 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