Home > Blockchain >  What http error code to return when "ETag" header field is malformed?
What http error code to return when "ETag" header field is malformed?

Time:02-16

RFC 7232 states the format of the If-Match and If-None-Match header fields. What http error code should be returned when the format of the header is wrong? 412 precondiction failed or 400 bad request? The RFC speaks only about "evaluate the If-Match precondition".

CodePudding user response:

400 is the appropriate status code here, since this is a case of "malformed request syntax". 412 would be a misleading response, since the client wouldn't know there was anything wrong with how it formatted its request.

CodePudding user response:

You can use both but i think than 412 will be the most precise and correct.

MDN use specifically ETag as exemple of HTTP Code 412

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412

  • Related