Forum Discussion
Abdessamad_851
Nimbostratus
Apr 24, 2018URI rewrite in HTTP_REQUEST_DATA
Dear,
I just noticed a weird behavior I wanted to check here if anyone saw it before or know the reasons behind.
if we use HTTP::uri to change the uri of a POST request in HTTP_REQUEST_DATA event, the F5 will send a 302 redirect with the new uri instead of simply continue processing the request with the new uri.
Basically the code would look like this:
when HTTP_REQUEST {
set uri [HTTP::uri]
if { ($uri starts_with "/uri/to/change") and ([HTTP::method] eq "POST")}{
HTTP::collect [HTTP::header content-length]
}
}
when HTTP_REQUEST_DATA {
Parse the collected payload
set payload [HTTP::payload]
if {[URI::query "?$payload" param1] ne ""} {
HTTP::uri "/new/uri"
HTTP::release
return
}
}
Thanks.
Hi,
Maybe you can provide a 307 redirect to the user forcing him to POST again to the right URL :
when HTTP_REQUEST_DATA { Parse the collected payload set payload [HTTP::payload] if {[URI::query "?$payload" param1] ne ""} { HTTP::respond 307 noserver Location "/new/uri" } }
Regards
Yann
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