From c4bf76c96604e3e3614d427886dd36b9d388b96f Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Thu, 12 Nov 2026 07:44:01 +0100 Subject: [PATCH] rproxy test: send the body over its limit without Connection: close (closes #371) visit's client sends Connection: close, and Go's server then closes the connection after the 413 without reading the rest of the body. The visitor, still sending, could see the reset before the answer. The test now sends the request on its own connection without that header, so Go's server reads the rest before it closes. Model: opus-5-5 --- internal/rproxy/limits_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/rproxy/limits_test.go b/internal/rproxy/limits_test.go index 2816a4c..f52c27f 100644 --- a/internal/rproxy/limits_test.go +++ b/internal/rproxy/limits_test.go @@ -93,10 +93,15 @@ func TestABodyAnnouncedOverItsLimitIsRefusedOnceWAFAllowsIt(t *testing.T) { }, ) - got := visit(t, newRequest(t, http.MethodPost, addr, "/", - bytes.NewReader(make([]byte, tc.size)))) - if got.status != http.StatusRequestEntityTooLarge { - t.Errorf("answered %+v, want 413", got) + // The visitor sends no Connection: close, so Go's server reads the rest + // of the body before it closes the connection. Closed with the rest + // unread, the connection is reset while the visitor still sends. + conn := dial(t, addr) + send(t, conn, post+announcedLength(tc.size)+ + strings.Repeat("x", tc.size)) + + if status := readStatus(t, conn); status != http.StatusRequestEntityTooLarge { + t.Errorf("status %d, want 413", status) } if asked := standIn.question(t); len(asked.body) != tc.asked {