Submitted by nitori in technology
I'm so bored I just popped up my browser's devtools to inspect the network activity while I submitted this post. Surprisingly server gave me a 302 instead of a 201 which I expected, since the latter is for when you create a resource which is what I'm semantically doing when I submit a post with an HTTP POST.
So I decided to test for myself with a VPS and do a quick CGI script with POSIX shell script to return a 201 and a Location header, thinking the browser will automatically redirect to the url I set for said header. And it did return a 201, but not redirect.
With curious intent I searched and it does seem like you aren't really supposed to redirect automatically, and 303 is the better response as the spec even says it's one of its purposes. Meanwhile 302 is supposed to really just say that the resource is temporarily in another, which I don't think fits with what the submit form does...
So yeah please use 303 not 302 :P
hollyhoppet wrote
whatever you do, do not tell the cops