I have a great conceptual discussion with my coworkers about the use of Location header in 202 Accepted response.
The story began analyzing the behavior of PHP header() function from here. The interesting excerpt:
The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless the 201 or a 3xx status code has already been set.
They didn't include 202 status code in this default behavior. It seems like they don't expect that 202 response has a Location and indeed:
header("HTTP/1.1 202");
header("Location: http://example.com");
redirect the client to Location URL. Of course, it is possible to change this behavior with third parameter of header() function but what attracted my attention was: Why they understood that by default 202 is not expected to hold a Location header?
Then I review the RFC looking for the official meaning of 202 status. The interesting excerpt:
The entity returned with this response SHOULD include an indication of the request's current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.
It doesn't explicitly refer to Location header like previous (in the same RFC doc) 201 response does. That would probably be the reason why PHP guys understood that 202 response should not hold Location header. Would a pointer be interpreted as Location header or PHP guys made a wrong assumption? If the standard allow Location header with 202 response: should not be the official documentation more explicit like 201 response definition?
Finally I reviewed the most recently RFC version and find a little change in redaction:
The representation sent with this response ought to describe the request's current status and point to (or embed) a status monitor that an provide the user with an estimate of when the request will be fulfilled.
Again it is not explicit enough to assume that point to means Location header.
In short, after above revisions: Am I being RFC-compliant using Location header with 202 response?
Location
header field is allowed for it. – Tinder