Forum Discussion
HTTP redirect conserving the payoad in the POST
Hi
I'm trying to redirect a specific conecction based in a payload information. If i found a specific ID in the payload, i want to redirect that connection to a server in the cloud. The redirect works, but the payload it's missing in the process. This is my irule (made following some post in this site).
when RULE_INIT { set static::ext_url "http://www.somewhereincloud.mx/uri } when HTTP_REQUEST { if {[HTTP::method] eq "POST"} { if { [HTTP::header Content-Length] ne "" and [HTTP::header value Content-Length] <= 1048576 } { set content_length [HTTP::header value Content-Length] } else { set content_length 1048576 } if { $content_length > 0 } { HTTP::collect $content_length } } } when HTTP_REQUEST_DATA { Do stuff with the payload set payload [HTTP::payload] set client [findstr $payload "12345<" "11” "<"] log local0. $payload log local0. $entidad Redirect if {$client equals "12345”} { set content "< script type=text/javascript language=javascript> \ function s(){document.f.submit();} \ "
foreach p [split [HTTP::payload] &] {
set name [URI::decode [getfield $p = 1]]
set value [URI::decode [getfield $p = 2]]
set content "${content}"
}
HTTP::respond 302 content $content
log local0. "this is the content: $content"
} }
I'm very new working with irules and i will appreciate your Help
5 Replies
- Kevin_Stewart
Employee
The easiest thing may just be to issue a 307 redirect, which should (in most browsers) honor the initial request method:
when RULE_INIT { set static::ext_url "http://www.somewhereincloud.mx/uri" } when HTTP_REQUEST { if { [HTTP::method] eq "POST" } { if { [HTTP::header Content-Length] ne "" and [HTTP::header value Content-Length] <= 1048576 } { set content_length [HTTP::header value Content-Length] } else { set content_length 1048576 } if { $content_length > 0 } { HTTP::collect $content_length } } } when HTTP_REQUEST_DATA { See if the ID field is in the POST if { [string tolower [HTTP::payload]] contains "id=" } { get the ID value if { [URI::query ?[HTTP::payload] id] equals "12345" } { perform 307 redirect HTTP::respond 307 Location $static::ext_url } } }
- Kevin_Stewart
Employee
I would agree that the 307 method would be easier, but the 200 option with the auto-posting hidden form is actually how many SAML implementations work, and is pretty standard. That said, you could definitely alter the above HTML to produce a visible alert and continue button.
- Alejandro_Reyes
Nimbostratus
Hi, Thank You Kevin for your answer. I was testing the 307 method in the irule and in a capture a could saw a 404 code.
This is a little complicated, because the customer is testing in a application developed in .net instead in a browser.
I'm will test the 200 method and i will let you know the results.
Regards
- Kevin_Stewart
Employee
A 404 would of course indicate "file not found". I would compare the client side request in each method, and in a direct interaction with this remote service. I'm guessing there's something unique you have to do when calling this service that isn't identical to the local requests.
- Irvin_Quevedo_3
Nimbostratus
If the path/URI is correct, what would be the correct syntax to redirect the payload, it seems to me that the problem continues to be the correct syntax to send this POST
static::ext_url
Recent Discussions
Related Content
* 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