408 Request Timeout

HTTP 408 Request Timeout 客户端错误响应状态码表示服务器希望关闭这个未使用的连接。一些服务器会在空闲连接上发送 408即使客户端之前没有发出任何请求

服务器应该在响应中发送 Connection: close 头部字段,因为 408 表示服务器已决定关闭连接而不是继续等待。

由于一些浏览器(如 Chrome 和 Firefox)使用 HTTP 预连接机制来加速浏览,因此此响应的使用率大大增加。

注意:有些服务器会关闭连接而不发送此消息。

状态

http
408 Request Timeout

示例

表单提交超时

以下示例显示了当 <input type="file"> 元素在表单提交时(使用 method="post")上传图像时,客户端可能发送的内容

http
POST /upload HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----Boundary1234
Content-Length: 4012345

------Boundary1234
Content-Disposition: form-data; name="file"; filename="myImage.jpg"
Content-Type: image/jpeg

\xFF\xD8\xFF\xE0\x00...(binary data)
------Boundary1234--

如果由于网络问题或延迟导致数据未完全接收,服务器可能会使连接超时。客户端可以再次重复请求,并且将使用新的连接。

http
HTTP/1.1 408 Request Timeout
Content-Type: text/html

<html>
<head>
    <title>408 Request Timeout</title>
</head>
<body>
    <h1>408 Request Timeout</h1>
    <p>Failed to process request in time. Please try again.</p>
</body>
</html>

规范

规范
HTTP 语义
# 状态.408

另见