Forum Discussion

Gerald_Meese's avatar
Jan 18, 2018

iRule - Do HTTP::redirect while preserving the POST method

Hello,

I'm using the following iRule to do a redirect to a specific URI :

when HTTP_REQUEST {
if {[HTTP::uri] starts_with  "/internalURI"} {
    set logindata [b64encode "username:password"]   
    HTTP::header replace Authorization "Basic $logindata"
} else {
    HTTP::redirect "/internalURI"
}

The application owner noticed that the POST request (SOAP payload) is transformed in a GET when the F5 sends the traffic to the backend.

I read that this is due to the redirected, I found out info to solve that issue whith a HTTP::response 307 but I'm wondering how to fix that with an HTTP::redirect.

Any help would be appreciated 🙂 Thanks !

Gerald

1 Reply

  • Hi,

     

    Http::redirect respond with a 302 code and Location header set with new URL.

     

    It never define if the method must be preserved or not!

     

    In HTTP RFC, look at this text

     

    Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used instead.

     

    So the 307 is the good response which can only be set with HTTP::respond command