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 {