HTTP状态码参考 - 完整HTTP响应代码列表 在线工具
搜索、筛选和复制所有HTTP状态码(1xx-5xx),包含描述、用例和响应示例。交互式参考 — 100%客户端处理,不向服务器发送数据。
找到 61 个状态码
The server is switching protocols as requested by the client.
The server has received and is processing the request, but no response is available yet.
Used to return response headers before the final HTTP message.
The request succeeded.
The request succeeded and a new resource was created.
The request has been accepted for processing, but processing is not complete.
The returned metadata is not exactly the same as available from the origin server.
The server successfully processed the request but is not returning any content.
The server successfully processed the request and asks the client to reset the document view.
The server is delivering only part of the resource due to a range header sent by the client.
The message body contains multiple status codes for different operations.
The members of a DAV binding have already been enumerated in a previous reply.
The server has fulfilled a GET request for the resource with instance manipulations applied.
The request has more than one possible response.
The URL of the requested resource has been changed permanently.
The URI of requested resource has been changed temporarily.
The server sent this response to direct the client to get the requested resource at another URI with a GET request.
The resource has not been modified since the version specified by the request headers.
The server sends this response to redirect the client, guaranteeing the same HTTP method will be used.
The resource has been permanently moved, and the same HTTP method must be used.
The server cannot process the request due to something perceived to be a client error.
The client must authenticate itself to get the requested response.
Reserved for future use. Originally created for digital payment systems.
The client does not have access rights to the content.
The server cannot find the requested resource.
The request method is known by the server but is not supported by the target resource.
The server cannot produce a response matching the list of acceptable values defined in the request headers.
The client must first authenticate itself with the proxy.
The server timed out waiting for the request.
The request conflicts with the current state of the server.
The content has been permanently deleted from the server with no forwarding address.
The server rejects the request because the Content-Length header field is not defined.
The client has indicated preconditions in its headers which the server does not meet.
The request entity is larger than limits defined by the server.
The URI requested by the client is longer than the server is willing to interpret.
The media format of the requested data is not supported by the server.
The range specified by the Range header field in the request cannot be fulfilled.
The expectation given in the Expect request header could not be met by the server.
The server refuses the attempt to brew coffee with a teapot.
The request was directed at a server that is not able to produce a response.
The request was well-formed but was unable to be followed due to semantic errors.
The resource that is being accessed is locked.
The request failed because it depended on another request that failed.
The server is unwilling to risk processing a request that might be replayed.
The server refuses to perform the request using the current protocol.
The origin server requires the request to be conditional.
The user has sent too many requests in a given amount of time (rate limiting).
The server is unwilling to process the request because its header fields are too large.
The user agent requested a resource that cannot legally be provided.
The server has encountered a situation it does not know how to handle.
The request method is not supported by the server and cannot be handled.
The server got an invalid response while working as a gateway.
The server is not ready to handle the request.
The server is acting as a gateway and cannot get a response in time.
The HTTP version used in the request is not supported by the server.
The server has an internal configuration error during content negotiation.
The server is unable to store the representation needed to complete the request.
The server detected an infinite loop while processing the request.
Further extensions to the request are required for the server to fulfill it.
The client needs to authenticate to gain network access.
常见问题
什么是HTTP状态码?
HTTP状态码是Web服务器响应客户端请求时返回的三位数字。它们指示请求是否成功、被重定向或导致错误。状态码分为五类:1xx(信息性)、2xx(成功)、3xx(重定向)、4xx(客户端错误)和5xx(服务器错误)。它们由IETF在RFC 9110中定义,是Web工作原理的基础。
如何使用这个HTTP状态码参考工具?
在搜索栏中输入状态码编号(例如'404')或关键词(例如'not found'或'redirect'),即可立即找到相关代码。您还可以使用1xx-5xx按钮按类别筛选。点击任意状态码卡片可展开查看完整描述、常见用例和可复制的响应示例。使用复制按钮快速获取项目所需的代码或片段。
我的数据安全吗?会有数据发送到服务器吗?
此工具100%在客户端运行。所有HTTP状态码数据都静态嵌入在页面中——没有API调用、没有服务器请求、没有数据收集。您的搜索查询和交互永远不会离开您的浏览器。初始页面加载后,该工具可完全离线工作。
401 Unauthorized和403 Forbidden有什么区别?
401 Unauthorized表示请求缺少有效的身份验证凭据——客户端尚未表明身份。服务器在说'我不知道你是谁,请进行身份验证。'403 Forbidden表示服务器知道你是谁(你可能已经通过身份验证),但你没有访问该资源的权限。服务器在说'我知道你是谁,但你没有权限。'
301和308重定向有什么区别?
两者都表示永久重定向。301 Moved Permanently允许在重定向时更改HTTP方法(例如,POST可能变为GET)。308 Permanent Redirect保留原始HTTP方法。对于使用POST/PUT的API,308是更安全的选择。类似地,302与307的关系也是如此:302 Found允许方法更改,而307 Temporary Redirect保留方法。
为什么存在418 'I'm a teapot'状态码?
418 I'm a teapot于1998年在RFC 2324中作为愚人节玩笑定义,是Hyper Text Coffee Pot Control Protocol(HTCPCP)的一部分。虽然从标准角度来看它不是真正的HTTP状态码,但它已被广泛采用为彩蛋,并被许多HTTP库和框架所识别。为了完整性,它被包含在本参考中。
什么是WebDAV状态码?
WebDAV(Web Distributed Authoring and Versioning)是HTTP的扩展,允许客户端执行远程Web内容创作。它引入了额外的状态码,如207 Multi-Status、422 Unprocessable Content、423 Locked、424 Failed Dependency、507 Insufficient Storage和508 Loop Detected。这些代码在RFC 4918中定义,在现代REST API中被广泛使用(特别是422用于验证错误)。
代码示例
// HTTP Status Code lookup
const HTTP_STATUS_CATEGORIES = {
'1xx': 'Informational',
'2xx': 'Success',
'3xx': 'Redirection',
'4xx': 'Client Error',
'5xx': 'Server Error',
};
function getStatusCategory(code) {
if (code >= 100 && code < 200) return '1xx';
if (code >= 200 && code < 300) return '2xx';
if (code >= 300 && code < 400) return '3xx';
if (code >= 400 && code < 500) return '4xx';
if (code >= 500 && code < 600) return '5xx';
return 'Unknown';
}
const STATUS_CODES = {
200: 'OK',
201: 'Created',
204: 'No Content',
301: 'Moved Permanently',
302: 'Found',
304: 'Not Modified',
400: 'Bad Request',
401: 'Unauthorized',
403: 'Forbidden',
404: 'Not Found',
405: 'Method Not Allowed',
409: 'Conflict',
422: 'Unprocessable Content',
429: 'Too Many Requests',
500: 'Internal Server Error',
502: 'Bad Gateway',
503: 'Service Unavailable',
};
async function fetchWithStatusHandling(url, options = {}) {
try {
const response = await fetch(url, options);
const category = getStatusCategory(response.status);
switch (category) {
case '2xx':
if (response.status === 204) return { data: null, status: 204 };
return { data: await response.json(), status: response.status };
case '4xx':
const clientError = await response.json().catch(() => ({}));
throw {
status: response.status,
statusText: STATUS_CODES[response.status] || response.statusText,
message: clientError.message || `Client error: ${response.status}`,
isRetryable: response.status === 429,
retryAfter: response.headers.get('Retry-After'),
};
case '5xx':
throw {
status: response.status,
statusText: STATUS_CODES[response.status] || response.statusText,
message: `Server error: ${response.status}`,
isRetryable: [502, 503, 504].includes(response.status),
};
default:
throw new Error(`Unexpected status code: ${response.status}`);
}
} catch (error) {
if (error.status) throw error;
throw { status: 0, message: 'Network error', isRetryable: true };
}
}