When to reply 400 Bad Request

Posted by KajMagnus on Pro Webmasters See other posts from Pro Webmasters or by KajMagnus
Published on 2011-06-28T17:41:46Z Indexed on 2011/06/29 0:32 UTC
Read the original article Hit count: 298

Filed under:

According to www.w3.org, a Web server should reply with status code 400 Bad Request if:

"The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications"

Does that mean only request that violates some HTTP spec?
Or does it include a request that my particular Web app thinks is broken?
When would you reply 400?

For example, if my Web app expects a query string to always include a "function=..." parameter, would you reply code 400 Bad Request or 403 Forbidden? (403 means that "The server understood the request, but is refusing to fulfill it.")

© Pro Webmasters or respective owner

Related posts about http