# net/http: invalid header field value for "X-Custom-Header"

- **ID:** `go/http-header-value-invalid`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Header values contain characters not allowed by HTTP spec (e.g., newlines, control chars), causing WriteHeader to fail.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   Use httpguts.ValidHeaderFieldValue to validate before setting
   ```
2. **** (85% success)
   ```
   Sanitize input by stripping invalid characters: strings.Map(func(r rune) rune { if r < 32 || r > 126 { return -1 }; return r }, val)
   ```

## Dead Ends

- **** — Escaping may change semantics; proper sanitization needed (60% fail)
- **** — May break client expectations if header is required (40% fail)
