HTTPQUERY

学习 · 测试 · 验证 HTTP —— 方法(含新方法 QUERY)、状态码与实时请求

English

HTTP 状态码

按类别浏览状态码。展开任意一行即可查看该状态码的真实 HTTP 报文示例。

1xx信息响应(Informational)

100Continue客户端应继续发送请求体。查看示例
                POST /uploads HTTP/1.1
Host: example.com
Content-Length: 5242880
Expect: 100-continue

HTTP/1.1 100 Continue

(client now streams the 5 MB body)

HTTP/1.1 201 Created
Location: /uploads/8f2c
              
101Switching Protocols服务器同意切换协议(如升级到 WebSocket)。查看示例
                GET /chat HTTP/1.1
Host: example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
              

2xx成功(Success)

200OK请求成功,响应含所请求的资源。查看示例
                GET /products/42 HTTP/1.1
Host: example.com

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 51

{ "id": 42, "name": "Trailhead Boot", "price": 189 }
              
201Created请求成功且创建了新资源。查看示例
                POST /products HTTP/1.1
Host: example.com
Content-Type: application/json

{ "name": "Ridge Boot", "price": 210 }

HTTP/1.1 201 Created
Location: /products/43
Content-Type: application/json

{ "id": 43, "name": "Ridge Boot", "price": 210 }
              
204No Content成功但无响应体。查看示例
                DELETE /products/43 HTTP/1.1
Host: example.com

HTTP/1.1 204 No Content

(no body)
              

3xx重定向(Redirection)

301Moved Permanently资源已永久移动到 Location 指向的地址。查看示例
                GET /old-path HTTP/1.1
Host: example.com

HTTP/1.1 301 Moved Permanently
Location: https://example.com/new-path
              
302Found资源临时位于 Location。查看示例
                GET /account HTTP/1.1
Host: example.com

HTTP/1.1 302 Found
Location: /login
              
304Not Modified缓存有效,可直接使用本地副本。查看示例
                GET /logo.png HTTP/1.1
Host: example.com
If-None-Match: "9c2e-abc123"

HTTP/1.1 304 Not Modified
ETag: "9c2e-abc123"

(no body — reuse the cached copy)
              

4xx客户端错误(Client Error)

400Bad Request请求语法或参数有误。查看示例
                POST /products HTTP/1.1
Host: example.com
Content-Type: application/json

{ "price": "not-a-number" }

HTTP/1.1 400 Bad Request
Content-Type: application/json

{ "error": "price must be a number" }
              
401Unauthorized需要身份认证。查看示例
                GET /account HTTP/1.1
Host: example.com

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api"
              
403Forbidden已认证但无权限。查看示例
                DELETE /users/1 HTTP/1.1
Host: example.com
Authorization: Bearer <valid-token>

HTTP/1.1 403 Forbidden
Content-Type: application/json

{ "error": "admin role required" }
              
404Not Found找不到目标资源。查看示例
                GET /products/9999 HTTP/1.1
Host: example.com

HTTP/1.1 404 Not Found
Content-Type: application/json

{ "error": "product 9999 not found" }
              
405Method Not Allowed该资源不支持所用方法。查看示例
                DELETE /products HTTP/1.1
Host: example.com

HTTP/1.1 405 Method Not Allowed
Allow: GET, POST, QUERY
              
418I'm a teapot我是茶壶——RFC 2324 的彩蛋状态码。查看示例
                BREW /coffee HTTP/1.1
Host: teapot.example

HTTP/1.1 418 I'm a teapot
Content-Type: text/plain

I refuse to brew coffee — I am a teapot.
              
429Too Many Requests请求过于频繁,被限流。查看示例
                GET /api/search HTTP/1.1
Host: example.com

HTTP/1.1 429 Too Many Requests
Retry-After: 30
Content-Type: application/json

{ "error": "rate limit exceeded" }
              

5xx服务器错误(Server Error)

500Internal Server Error服务器内部错误。查看示例
                GET /report HTTP/1.1
Host: example.com

HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{ "error": "unexpected server error" }
              
502Bad Gateway网关从上游收到无效响应。查看示例
                GET /api/users HTTP/1.1
Host: gateway.example.com

HTTP/1.1 502 Bad Gateway
Content-Type: text/plain

upstream sent an invalid response
              
503Service Unavailable服务暂时不可用(过载或维护)。查看示例
                GET / HTTP/1.1
Host: example.com

HTTP/1.1 503 Service Unavailable
Retry-After: 120
Content-Type: text/plain

under maintenance — try again shortly