v2.1 task 01: state the ReverseProxy facts (ErrorHandler before headers, ErrAbortHandler mid-body); note the refusal-ending
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,23 @@ responses under the given test's load; `TestQueueFullIs503` flaked on it. The re
|
||||
`ErrorHandler` already sees `context.Canceled` for the "client gone before the response" case
|
||||
and currently returns without leaving a trace, which is why the post-hoc check was there.
|
||||
|
||||
## Facts about `httputil.ReverseProxy` (Go 1.26) — you cannot read its source from here
|
||||
|
||||
The standard library lives outside the repository and the sandbox refuses reads there; do not
|
||||
try. What you need:
|
||||
|
||||
- `ServeHTTP` calls `ErrorHandler(w, req, err)` when the outgoing request fails **before any
|
||||
response byte was written** — for a client that left, `err` satisfies
|
||||
`errors.Is(err, context.Canceled)`. After the response headers were written, `ErrorHandler`
|
||||
is never called.
|
||||
- If copying the response body to the client fails (the client left mid-body), `ServeHTTP`
|
||||
**panics with `http.ErrAbortHandler`**; v1.1's deferred `recover` in `forward.go` already
|
||||
turns that into the 499 row and re-panics.
|
||||
- `ServeHTTP` returning normally therefore means the response was delivered in full (or
|
||||
`ErrorHandler` answered). The request's context may nonetheless already be cancelled at that
|
||||
moment — the server cancels it when the client's connection closes — which is exactly the
|
||||
signal the current code misreads.
|
||||
|
||||
## Files
|
||||
|
||||
- Copy: `internal/proxy/served_test.go`
|
||||
|
||||
Reference in New Issue
Block a user