# http: wrote more than the declared Content-Length

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

## Root Cause

Handler set Content-Length header explicitly but wrote more bytes than declared, or middleware re-wrote the body.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   Buffer the response with bytes.Buffer, then set Content-Length to buf.Len() before w.Write.
   ```
2. **** (92% success)
   ```
   Do not set Content-Length manually; let net/http chunk or compute it.
   ```

## Dead Ends

- **** — Clients hang waiting for the remaining bytes. (85% fail)
- **** — Headers already sent; no effect. (90% fail)
