HTTP错误代码
HTTP错误代码
图片纯属搞笑,写过http代码仅仅是个头,他的意思都是人赋予的,纠正几个观点,402和“当初制定出402的那帮人是怎么想的,为什么最后没有实现,将来到底有没有一天会实现”是没有关系的,402是业务逻辑返回的代码,一定是由程序员来实现,而不是由指定的那帮人来实现。并不是说payment required就一定要用402,而是402的一般是payment required。程序员可以不实现402,可以花式实现402。你没付费,我可以不让你402,从逻辑上讲,我可以让你403 forbidden,我也可以给你一个302跳转,我也可以给你一个200界面要求充值,这个并不冲突。敲黑板,相比于402,我们更需要关注5XX错误代码。下面是干货:(来源:go包源码,提供了RFC出处)
作者:大舒
链接:https://www.zhihu.com/question/30692393/answer/49099750
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
HTTP status codes, defined in RFC 2616.
StatusContinue = 100
StatusSwitchingProtocols = 101
StatusOK = 200
StatusCreated = 201
StatusAccepted = 202
StatusNonAuthoritativeInfo = 203
StatusNoContent = 204
StatusResetContent = 205
StatusPartialContent = 206
StatusMultipleChoices = 300
StatusMovedPermanently = 301
StatusFound = 302
StatusSeeOther = 303
StatusNotModified = 304
StatusUseProxy = 305
StatusTemporaryRedirect = 307
StatusBadRequest = 400
StatusUnauthorized = 401
StatusPaymentRequired = 402
StatusForbidden = 403
StatusNotFound = 404
StatusMethodNotAllowed = 405
StatusNotAcceptable = 406
StatusProxyAuthRequired = 407
StatusRequestTimeout = 408
StatusConflict = 409
StatusGone = 410
StatusLengthRequired = 411
StatusPreconditionFailed = 412
StatusRequestEntityTooLarge = 413
StatusRequestURITooLong = 414
StatusUnsupportedMediaType = 415
StatusRequestedRangeNotSatisfiable = 416
StatusExpectationFailed = 417
StatusTeapot = 418
StatusInternalServerError = 500
StatusNotImplemented = 501
StatusBadGateway = 502
StatusServiceUnavailable = 503
StatusGatewayTimeout = 504
StatusHTTPVersionNotSupported = 505
// New HTTP status codes from RFC 6585. Not exported yet in Go 1.1.
// See discussion at https://codereview.appspot.com/7678043/
statusPreconditionRequired = 428
statusTooManyRequests = 429
statusRequestHeaderFieldsTooLarge = 431
statusNetworkAuthenticationRequired = 511
该页面评论已关闭