# error: Get "https://example.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

- **ID:** `go/http-client-request-timeout-context-deadline`
- **Domain:** go
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

HTTP客户端请求设置了超时，但服务器响应时间超过该超时，导致请求被取消。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "GET", url, nil)
resp, err := http.DefaultClient.Do(req)
   ```
2. **** (85% success)
   ```
   使用http.Client{Timeout: 10 * time.Second}并确保服务器端处理快速响应。
   ```

## Dead Ends

- **** — 临时增加超时可能掩盖服务器性能问题，且在高负载下仍会失败。 (80% fail)
- **** — 如果客户端超时设置错误，复用无效，且可能引入并发安全问题。 (60% fail)
