流式响应
流式响应:Server-Sent Events、NDJSON、分块传输、逐字节滴送和流式 JSON 数组。响应缓冲已关闭,每个事件都立即发出,所以客户端能在数据产生时就看到。客户端一断开,流就会停止。
你的账号已解锁这些端点。在每个端点的页面上用 Try it 发送请求。
- GET
https://api.testingapis.com/api/stream/chunked/{n}Send a plain-text response in chunked transfer encodingSend a plain-text response in chunked transfer encoding. - GET
https://api.testingapis.com/api/stream/dripDrip bytes slowly over a durationDrip bytes slowly over a duration. - GET
https://api.testingapis.com/api/stream/json-array/{n}Stream a JSON array one element at a timeStream a JSON array one element at a time. - GET
https://api.testingapis.com/api/stream/ndjson/{n}Stream newline-delimited JSON, one object per lineStream newline-delimited JSON, one object per line. - GET
https://api.testingapis.com/api/stream/sseStream Server-Sent EventsStream Server-Sent Events. - GET
https://api.testingapis.com/api/stream/sse/stockStream a deterministic stock ticker as Server-Sent EventsStream a deterministic stock ticker as Server-Sent Events.
请求示例
Drip bytes slowly over a duration. 完整参考和 Send 按钮(英文).
cURL
curl -X GET "https://api.testingapis.com/api/stream/drip?durationMs=500&bytes=5"响应 · 200 OK
<binary body: 5 bytes, application/octet-stream>