HTTP 提供了豐富的狀態(tài)碼供我們使用蚯舱,正確的使用狀態(tài)碼可以讓響應(yīng)數(shù)據(jù)更具可讀性。
200 OK - 對成功的 GET毅弧、PUT、PATCH 或 DELETE 操作進行響應(yīng)尸变。也可以被用在不創(chuàng)建新資源的 POST 操作上
201 Created - 對創(chuàng)建新資源的 POST 操作進行響應(yīng)忿等。應(yīng)該帶著指向新資源地址的 Location 頭
202 Accepted - 服務(wù)器接受了請求,但是還未處理咽瓷,響應(yīng)中應(yīng)該包含相應(yīng)的指示信息设凹,告訴客戶端該去哪里查詢關(guān)于本次請求的信息
204 No Content - 對不會返回響應(yīng)體的成功請求進行響應(yīng)(比如 DELETE 請求)
304 Not Modified - HTTP緩存header生效的時候用
400 Bad Request - 請求異常,比如請求中的body無法解析
401 Unauthorized - 沒有進行認證或者認證非法
403 Forbidden - 服務(wù)器已經(jīng)理解請求茅姜,但是拒絕執(zhí)行它
404 Not Found - 請求一個不存在的資源
405 Method Not Allowed - 所請求的 HTTP 方法不允許當(dāng)前認證用戶訪問
410 Gone - 表示當(dāng)前請求的資源不再可用闪朱。當(dāng)調(diào)用老版本 API 的時候很有用
415 Unsupported Media Type - 如果請求中的內(nèi)容類型是錯誤的
422 Unprocessable Entity - 用來表示校驗錯誤
429 Too Many Requests - 由于請求頻次達到上限而被拒絕訪問
[轉(zhuǎn)載],
[原文見] https://laravel-china.org/articles/20062
100 => 'Continue', //繼續(xù)
101 => 'Switching Protocols', //交換協(xié)議
102 => 'Processing', //處理 // RFC2518
103 => 'Early Hints', //提前暗示
200 => 'OK',
201 => 'Created',
202 => 'Accepted', //認可的
203 => 'Non-Authoritative Information', //非授權(quán)信息
204 => 'No Content', //無內(nèi)容
205 => 'Reset Content', //重置內(nèi)容
206 => 'Partial Content', //部分內(nèi)容
207 => 'Multi-Status', //多狀態(tài) // RFC4918
208 => 'Already Reported', //已經(jīng)播報 // RFC5842
226 => 'IM Used', //異步使用 // RFC3229
300 => 'Multiple Choices', //多選
301 => 'Moved Permanently', //永久移除
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
307 => 'Temporary Redirect', //臨時跳轉(zhuǎn)
308 => 'Permanent Redirect', //永久跳轉(zhuǎn) // RFC7238
400 => 'Bad Request', //無效請求
401 => 'Unauthorized', //未授權(quán)請求
402 => 'Payment Required', //請求不允許
403 => 'Forbidden', //請求被禁止
404 => 'Not Found', //請求對象不存在
405 => 'Method Not Allowed', //方法不允許
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required', //需要代理身份驗證
408 => 'Request Timeout', //請求超時
409 => 'Conflict', //沖突
410 => 'Gone', //請求丟失
411 => 'Length Required',
412 => 'Precondition Failed', //先決條件失敗
413 => 'Payload Too Large', //負載太大
414 => 'URI Too Long', //url太長
415 => 'Unsupported Media Type', //媒體類型不支持
416 => 'Range Not Satisfiable', //范圍不適合
417 => 'Expectation Failed', //預(yù)期失敗
418 => 'I\'m a teapot', // RFC2324
421 => 'Misdirected Request', //誤導(dǎo)請求 // RFC7540
422 => 'Unprocessable Entity', //無法處理的實體 // RFC4918
423 => 'Locked', // RFC4918
424 => 'Failed Dependency', // RFC4918
425 => 'Reserved for WebDAV advanced collections expired proposal', //保留用于WebDAV高級集合過期提案 // RFC2817
426 => 'Upgrade Required', // RFC2817
428 => 'Precondition Required', //要求先決條件 // RFC6585
429 => 'Too Many Requests', // RFC6585
431 => 'Request Header Fields Too Large', //請求頭字段太大 // RFC6585
451 => 'Unavailable For Legal Reasons', //因法律原因無法獲得 // RFC7725
499 => 'Client has closed connection' //客戶端主動關(guān)閉連接
500 => 'Internal Server Error', //內(nèi)部服務(wù)器錯誤
501 => 'Not Implemented', //未實現(xiàn)
502 => 'Bad Gateway', //無效網(wǎng)關(guān)
503 => 'Service Unavailable', //服務(wù)不可用
504 => 'Gateway Timeout', //網(wǎng)關(guān)連接超時
505 => 'HTTP Version Not Supported', //http 版本不支持
506 => 'Variant Also Negotiates', //服務(wù)器存在內(nèi)部配置錯誤 // RFC2295
507 => 'Insufficient Storage', //遠程服務(wù)器返回錯誤 // RFC4918
508 => 'Loop Detected', // RFC5842
510 => 'Not Extended', // RFC2774
511 => 'Network Authentication Required', //客戶端需要進行身份驗證以獲得網(wǎng)絡(luò)訪問。