HTTP 狀態碼及含義


來自 Koa.js 官方文檔中關於設置請求響應的部分 response.status=,列出了從 1xx ~ 5xx HTTP 狀態碼及含義,現摘錄如下:

  • 100 "continue"
  • 101 "switching protocols"
  • 102 "processing"
  • 200 "ok"
  • 201 "created"
  • 202 "accepted"
  • 203 "non-authoritative information"
  • 204 "no content"
  • 205 "reset content"
  • 206 "partial content"
  • 207 "multi-status"
  • 208 "already reported"
  • 226 "im used"
  • 300 "multiple choices"
  • 301 "moved permanently"
  • 302 "found" 資源臨時不可用,但在其他位置找到了,返回 302 同時帶上Location: 新的資源地址 響應頭。客戶端根據新地址再次請求。
    • 假如第一次請求使用的 POST,后面這次重新請求瀏覽器有可能變成 GET。
    • 如果想要兩次請求保持一致的請求方式,使用 307
    • 運用場景:某些原因資源無法訪問了,此時為了不讓搜索引擎更新,可使用 302 告訴引擎資源還在。
  • 303 "see other"
  • 304 "not modified"
  • 305 "use proxy"
  • 307 "temporary redirect"
    • 和 302 一模一樣,區別在於兩次請求保持一致的 http verb
  • 308 "permanent redirect"
  • 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 timeout"
  • 409 "conflict"
  • 410 "gone"
  • 411 "length required"
  • 412 "precondition failed"
  • 413 "payload too large"
    • 比如 post 的數據也就是request body過大
  • 414 "uri too long"
  • 415 "unsupported media type"
  • 416 "range not satisfiable"
  • 417 "expectation failed"
  • 418 "I'm a teapot"
  • 422 "unprocessable entity"
  • 423 "locked"
  • 424 "failed dependency"
  • 426 "upgrade required"
  • 428 "precondition required"
  • 429 "too many requests"
  • 431 "request header fields too large"
  • 500 "internal server error"
  • 501 "not implemented"
  • 502 "bad gateway"
  • 503 "service unavailable"
  • 504 "gateway timeout"
  • 505 "http version not supported"
  • 506 "variant also negotiates"
  • 507 "insufficient storage"
  • 508 "loop detected"
  • 510 "not extended"
  • 511 "network authentication required"

相關資源


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM