1. 給開發者的 Web 技術文件
  2. HTTP
  3. Reference
  4. HTTP 回應狀態碼
  5. 411 Length Required

此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。

View in English Always switch to English

411 Length Required

HTTP 411 Length Required 用戶錯誤回應狀態碼表示伺服器拒絕接受沒有定義 Content-Length 標頭的請求。

備註: 在以一系列分塊發送數據時,會省略 Content-Length 標頭,而在每個分塊的開頭,當前分塊的長度需要以十六進制格式包含。詳情請參見 Transfer-Encoding

狀態

http
411 Length Required

範例

分塊的 POST 請求

以下請求使用分塊傳輸,這在某些情況下是預設的數據傳輸方式(例如寫入串流):

http
POST /translate/de HTTP/1.1
Host: api.example.com
Content-Type: application/json
Transfer-encoding: chunked
2C
{"text": "Hurry up, Ayşe is hungry!"}
0

在這種情況下,伺服器期望請求包含 Content-Length 標頭,否則將返回 411 回應:

http
HTTP/1.1 411 Length Required
Content-Type: application/json
Content-Length: 110
{
 "message": "請求必須包含 Content Length 標頭。",
 "documentation": "http://api/example.com/docs/errors",
}

規範

Specification
HTTP Semantics
# status.411

參見

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /