Reputation: 5169
What would be an appropriate HTTP response code for a server to send if it expects the ETag header to be set but the request does not contain it ? Would the most appropriate be BAD REQUEST (400) ?
Upvotes: 1
Views: 1305
Reputation: 42075
If what you mean is that a conditional request header field (such as If-None-Match) was missing, then the answer would be status 428 (see https://www.rfc-editor.org/rfc/rfc6585#section-3).
Upvotes: 2
Reputation: 7661
Is it a conditional GET? Because then a plain 200 OK with full body seems completely appropriate to me in case the validity of the client cache can not be verified.
Upvotes: 0
Reputation: 98015
The description in RFC 2616 defines Status 403 as "The server understood the request, but is refusing to fulfill it."
Since it is explicitly left up to the server to explain why the request was refused, a 403 with a body stating "All requests must include an ETag Header" would seem to be a correct response.
Status 400 is defined in that RFC as being due to "malformed syntax", which is not the same as receiving a request you didn't like the look of.
Upvotes: 2