http header 代码 413 和 414 之间的区别
difference between http header code 413 and 414
我正在开发一个简单的 Web 服务器,我想处理长 Get 值。
如果请求大于 4096,并且它是 GET 值,我想发送 header 代码给理解请求太大的客户端。
客户端在缓冲区中发送了一个巨大的 cookie,使其比我的网络服务器所能获得的更大。
我应该发送哪个 header 代码? 414 Request-URI 太长还是 413 负载太大?
client sends a huge cookie in buffer that make it larger than my web server can get.
客户端应该只发回您的网络服务器之前提供给客户端的 cookie。如果您自己的 cookie 太大而您的网络服务器无法处理,您需要缩短它们。
which header code should I send? 414 Request-URI Too Long or 413 Payload Too Large?
都没有。请求URI不是什么太长,所以414不合适。而一个GET
请求没有body,只有headers,所以413也不合适。
您应该使用的响应代码是 431 Request Header Fields Too Large
,它在 RFC 6585 Additional HTTP Status Codes:
中定义
5. 431 Request Header Fields Too Large
The 431 status code indicates that the server is unwilling to process
the request because its header fields are too large. The request MAY
be resubmitted after reducing the size of the request header fields.
It can be used both when the set of request header fields in total is
too large, and when a single header field is at fault. In the latter
case, the response representation SHOULD specify which header field
was too large.
For example:
HTTP/1.1 431 Request Header Fields Too Large
Content-Type: text/html
<html>
<head>
<title>Request Header Fields Too Large
</head>
<body>
<h1>Request Header Fields Too Large
<p>The "Example" header was too large.
</body>
</html>
Responses with the 431 status code MUST NOT be stored by a cache.
我正在开发一个简单的 Web 服务器,我想处理长 Get 值。 如果请求大于 4096,并且它是 GET 值,我想发送 header 代码给理解请求太大的客户端。
客户端在缓冲区中发送了一个巨大的 cookie,使其比我的网络服务器所能获得的更大。
我应该发送哪个 header 代码? 414 Request-URI 太长还是 413 负载太大?
client sends a huge cookie in buffer that make it larger than my web server can get.
客户端应该只发回您的网络服务器之前提供给客户端的 cookie。如果您自己的 cookie 太大而您的网络服务器无法处理,您需要缩短它们。
which header code should I send? 414 Request-URI Too Long or 413 Payload Too Large?
都没有。请求URI不是什么太长,所以414不合适。而一个GET
请求没有body,只有headers,所以413也不合适。
您应该使用的响应代码是 431 Request Header Fields Too Large
,它在 RFC 6585 Additional HTTP Status Codes:
5. 431 Request Header Fields Too Large The 431 status code indicates that the server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields. It can be used both when the set of request header fields in total is too large, and when a single header field is at fault. In the latter case, the response representation SHOULD specify which header field was too large. For example: HTTP/1.1 431 Request Header Fields Too Large Content-Type: text/html <html> <head> <title>Request Header Fields Too Large </head> <body> <h1>Request Header Fields Too Large <p>The "Example" header was too large. </body> </html> Responses with the 431 status code MUST NOT be stored by a cache.