Should I use HTTP 4xx to indicate HTML form errors?

前端 未结 4 1104
滥情空心
滥情空心 2020-12-19 04:33

I just spent 20 minutes debugging some (django) unit tests. I was testing a view POST, and I was expecting a 302 return code, after which I asserted a bunch database entitie

4条回答
  •  盖世英雄少女心
    2020-12-19 05:03

    You are right that 200 is wrong if the outcome is not success.

    I'd also argue that a success-with-redirect-to-result-page should be 303, not 302.

    4xx is correct for client error. 422 seems right to me. In any case, don't invent new 4xx codes without registering them through IANA.

提交回复
热议问题