正确的HTTP状态code错误的输入 [英] Right HTTP status code to wrong input

查看:317
本文介绍了正确的HTTP状态code错误的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最佳的HTTP响应code时不报200(一切OK),但错误输入?

What is optimal HTTP response Code when not reporting 200 (everything OK) but error in input?

一样,你的一些数据提交到服务器,它会回应你的数据是错误的。

Like, you submit some data to server, and it will response that your data is wrong

500 看起来更像是服务器问题结果
使用 200 带有警告/错误响应文本坏(允许缓存和一切不正确)结果
使用 204 和返回什么,也许是不错的(但很好的支持?)结果
使用 404 是错的,如果请求的路径(脚本),可在适当的地方

using 500 looks more like Server Issue
using 200 with warning/error response text is bad (allowing caching and everything is not OK)
using 204 and returning nothing, is maybe good (but well supported?)
using 404 is wrong if requested path (script) is available and in proper place

推荐答案

codeS开始4(4XX)都是为了客户的错误。也许400(错误请求)可能是适合这种情况?在<定义href=\"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\">http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html说:

Codes starting with 4 (4xx) are meant for client errors. Maybe 400 (Bad Request) could be suitable to this case? Definition in http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html says:

的请求无法被服务器理解,由于语法错误,客户端应该不重复不加修改的要求。

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

这篇关于正确的HTTP状态code错误的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆