@marcel91200 / caddy Mirror · read-only / commits / f357e2b6
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 04:45 UTC

reverseproxy: stabilise half-close test (#8049)

Zen Dodd committed Oct 3, 2026 at 11:46 UTC f357e2b6bf558fd4f67f510a529d7816b181ef12
1 file changed +6 -2
modules/caddyhttp/reverseproxy/streaming_test.go
+6 -2
@@ -3,6 +3,7 @@ package reverseproxy
3 import (
4 "bufio"
5 "bytes"
6 + "context"
7 "errors"
8 "io"
9 "net"
@@ -265,9 +266,9 @@ func TestHandlerUpgradedStreamHalfClose(t *testing.T) {
266 },
267 "backend close write": func(t *testing.T, cli, srv *net.TCPConn) {
268 mustCloseWrite(t, srv)
269 + mustReadEOF(t, cli)
270 mustWrite(t, cli, "client sends")
271 mustRead(t, srv, "client sends")
270 - mustReadEOF(t, cli)
272 },
273 "client close read": func(t *testing.T, cli, srv *net.TCPConn) {
274 mustCloseRead(t, cli)
@@ -276,9 +277,9 @@ func TestHandlerUpgradedStreamHalfClose(t *testing.T) {
277 },
278 "client close write": func(t *testing.T, cli, srv *net.TCPConn) {
279 mustCloseWrite(t, cli)
280 + mustReadEOF(t, srv)
281 mustWrite(t, srv, "backend sends")
282 mustRead(t, cli, "backend sends")
281 - mustReadEOF(t, srv)
283 },
284 }
285
@@ -315,6 +316,9 @@ func TestHandlerUpgradedStreamHalfClose(t *testing.T) {
316 h.connectionsMu = new(sync.Mutex)
317
318 frontend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
319 + // Isolate half-close propagation from request cancellation which has
320 + // its own backend-close path.
321 + r = r.WithContext(context.WithoutCancel(r.Context()))
322 _ = h.ServeHTTP(w, prepareTestRequest(r), caddyhttp.HandlerFunc(func(http.ResponseWriter, *http.Request) error {
323 return nil
324 }))