mirror of
https://github.com/caddyserver/caddy.git
synced 2026-11-21 15:29:45 +00:00
reverseproxy: align trailer tests with consumed-stream retry safety
Follow up report de1bcf6d-457c-4348-9d4e-5eeb41cc120b. Expect one transport attempt for consumed partial streams while keeping unread dial retries and fully buffered trailer replay covered. Validated the entire reverseproxy package with offline race-short tests in a loopback-only network namespace. Code written by GitHub Copilot (GPT-6.1 Sol, Claude Opus 5.5); reviewed by mholt. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
d52d097109
commit
2ee6bdf837
1 changed files with 9 additions and 6 deletions
|
|
@ -349,10 +349,7 @@ func TestRequestTrailersRetry(t *testing.T) {
|
|||
return nil, err
|
||||
}
|
||||
if tc.partial {
|
||||
_, err := io.ReadAll(r.Body)
|
||||
if err == nil {
|
||||
t.Error("partially consumed request body became replayable")
|
||||
}
|
||||
t.Error("partially consumed request body was retried")
|
||||
return nil, errors.New("consumed body is not replayable")
|
||||
}
|
||||
return transport.RoundTrip(r)
|
||||
|
|
@ -367,8 +364,14 @@ func TestRequestTrailersRetry(t *testing.T) {
|
|||
req = req.WithContext(ctx)
|
||||
rec := httptest.NewRecorder()
|
||||
err := h.ServeHTTP(rec, req, nil)
|
||||
if attempts != 2 {
|
||||
t.Fatalf("attempts=%d, want 2", attempts)
|
||||
wantAttempts := 2
|
||||
if tc.partial {
|
||||
// Consumed streams must stop before another transport attempt;
|
||||
// unread dial failures and fully buffered bodies remain replayable.
|
||||
wantAttempts = 1
|
||||
}
|
||||
if attempts != wantAttempts {
|
||||
t.Fatalf("attempts=%d, want %d", attempts, wantAttempts)
|
||||
}
|
||||
if tc.partial {
|
||||
if err == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue