W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2009

[whatwg] page refresh and resubmitting POST state

From: Jonas Sicking <jonas@sicking.cc>
Date: Fri, 22 May 2009 12:50:03 -0700
Message-ID: <63df84f0905221250y41f0ecd6xdd026116dc3aee43@mail.gmail.com>
On Fri, May 22, 2009 at 7:06 AM, Mike Wilson <mikewse at hotmail.com> wrote:
> - potentially add constructs to help users avoid the above
> ?resubmit question (this could f ex be through providing
> ?some support for PRG = Post-Redirect-Get, or other)

This is already supported. If you use a 302 or 303 redirect in
response to a POST this will redirect to a uri that the UA then GETs.
Refresing that page will simply result in a new GET to the second uri.

product.html contains a <form method=POST action=addToCart.cgi>.
addToCart.cgi processes the parameters received from the POST request
and replies with a 302 response with Location: displayCart.cgi.
displayCart.cgi lists what is in the shopping cart.

The result of this is that once the user submits the form on
product.html, the UA will make a POST request to addToCart.cgi, then
make a GET request to displayCart.cgi and display the result of that
page. If the user refreshes the UA will again make a GET request to
displayCart.cgi and display the result.

/ Jonas
Received on Friday, 22 May 2009 12:50:03 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:12 UTC