当我们在浏览网页的时候,经常会看到诸如 500 错误之类的讯息,这些错误代码所代表的含义作为网站的开发人员,应该必须了解的。
HTTP 的回应代码是三位数字,其中第一个数字定义了代码的类别:
范围 | 类别 | 含义 |
---|---|---|
100~199 | 讯息 | 请求被接收,正在处理 |
200~299 | 成功 | 动作被成功接收、理解和接受 |
300~399 | 重新导向 | 必须采取其他动作才能完成请求 |
400~499 | 用户错误 | 请求包含不良语法或无法完成 |
500~599 | 服务器错误 | 服务器无法处理的请求 |
其中较常见的 HTTP 回应代码有:
- 200: 请求成功
- 400: 语法错误
- 401: 未经授权
- 403: 禁止访问
- 404: 请求的网页不存在
- 500: 服务器错误
较为完整的有:
- 1xx: Informational - Request received, continuing process
- 100 - Continue
- 101 - Switching Protocols - 2xx: Success - The action was successfully received, understood, and accepted
- 200 - OK
- 201 - Created
- 202 - Accepted
- 203 - Non-Authoritative Information
- 204 - No Content
- 205 - Reset Content
- 206 - Partial Content - 3xx: Redirection - Further action must be taken in order to complete the request
- 300 - Multiple Choices
- 301 - Moved Permanently
- 302 - Moved Temporarily
- 303 - See Other
- 304 - Not Modified
- 305 - Use Proxy - 4xx: Client Error - The request contains bad syntax or cannot be fulfilled - translation: "you blew it."
- 400 - Bad Request
- 401 - Unauthorized
- 402 - Payment Required
- 403 - Forbidden
- 404 - Not Found
- 405 - Method Not Allowed
- 406 - Not Acceptable
- 407 - Proxy Authentication Required
- 408 - Request Time-out
- 409 - Conflict
- 410 - Gone
- 411 - Length Required
- 412 - Precondition Failed
- 413 - Request Entity Too Large
- 414 - Request-URI Too Large
- 415 - Unsupported Media Type - 5xx: Server Error - The server failed to fulfill an apparently valid request - translation: "the server blew it."
- 500 - Internal Server Error
- 501 - Not Implemented
- 502 - Bad Gateway
- 503 - Service Unavailable
- 504 - Gateway Time-out
- 505 - HTTP Version not supported