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

6

Comments

You must log in or register to comment.

nitori OP wrote

Though on the other hand maybe scratch that idea because I think this is gonna break plenty of old clients lol: https://http.dev/303

2

twovests wrote

this might be something with my caddy config and not postmill-- not 100% sure

2

nitori OP wrote

Nope, just tested with my own Postmill instance and it's returning a 302 there too after a POST. Though that one's behind an nginx, tho I doubt nginx mangles with status codes

2