# net/http: 请求已取消（等待标头时客户端超时已超时）

- **ID:** `go/deadline-exceeded-http-client`
- **领域:** go
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

HTTP客户端请求超时，因为服务器发送响应标头的时间超过了配置的超时时间或上下文截止时间。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Go 1.18 | active | — | — |
| Go 1.19 | active | — | — |
| Go 1.20 | active | — | — |

## 解决方案

1. ```
   Set a reasonable Timeout on the http.Client and use a context with deadline for the request
   ```
2. ```
   Implement retry logic with exponential backoff and jitter for transient network issues
   ```

## 无效尝试

- **** — This masks the underlying issue; if the server is slow or misconfigured, the request still fails eventually or blocks resources. (70% 失败率)
- **** — Retrying without backoff can overwhelm the server and cause cascading failures. (85% 失败率)
