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": "Requests must have a content length header.",
  "documentation": "http://api/example.com/docs/errors",
}

规范

规范
HTTP 语义
# status.411

另见