Replay an Http.Request in Play! Framework

I’d like to cross-post a question I’ve asked on Stackoverflow yesterday, because I wasn’t able to find any documentation about it.

Link to Stackoverflow question:

Post:

Is there a possibility in Play! Framework to “replay” a Http.Request ? Replay in the sense of re-applying the request as if it was received again.

Context Information
In my specific use-case I’m trying to resolve an issue where a POST request (eg. a form submission) is rejected if the user’s session is no longer valid. Responding to the POST request with a redirect to the login page will result in the POST data being lost. Which is obviously bad from the end-users perspective.

My current idea is to store the original Http.Request object in a HashMap (or any other kind of store) and then respond with a redirect to the login page. After the user has logged in again, the previously stored request should be replayed as if the user would have re-submitted the form, and the Result of this replay can then be returned back directly to the user.

The first part works fine, storing the original POST Http.Request in a HashMap and then flagging the user’s session so the original request can later be retrieved again. After the user has logged in, I can retrieve the original POST request, but I’m unsure if and how it is possible to replay this request now. I could probably convert the Http.Request to a WSRequest and send it from the backend to itself with a WSClient , but this seems a bit hacky, and there probably is a simpler solution.