# 客户端断开连接：发送请求体时客户端断开连接

- **ID:** `python/starlette-request-client-disconnect`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

客户端在请求体完全接收之前关闭了连接。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (80% 成功率)
   ```
   Handle the exception gracefully and log it: except ClientDisconnected: logger.warning('Client disconnected')
   ```
2. **** (70% 成功率)
   ```
   Use a middleware to catch and return a 499 status code
   ```

## 无效尝试

- **** — The request is incomplete; continuing may cause data corruption. (50% 失败率)
- **** — The client is gone; timeout won't help. (30% 失败率)
