| 1 | --- a/vendor/github.com/caddyserver/caddy/v2/modules/caddyhttp/idletimeout.go |
| 2 | +++ b/vendor/github.com/caddyserver/caddy/v2/modules/caddyhttp/idletimeout.go |
| 3 | @@ -69,8 +69,8 @@ |
| 4 | // IdleTimeoutReader wraps a request body with IdleDeadline, resetting |
| 5 | // the read deadline before every Read call instead of bounding the |
| 6 | // whole body transfer with a single hard deadline. |
| 7 | -// The deadline is cleared after an error (most likely io.EOF) is encountered when reading the body |
| 8 | -// to prevent context canceled error for h1 requests. |
| 9 | +// EOF clears the deadline to permit HTTP/1 keep-alive. |
| 10 | +// Failed reads keep it armed so net/http cannot block draining the body in Close. |
| 11 | // see: https://github.com/caddyserver/caddy/issues/8103 |
| 12 | type IdleTimeoutReader struct { |
| 13 | 	io.ReadCloser |
| 14 | @@ -108,7 +108,7 @@ |
| 15 | 	r.Deadline.transferred += int64(n) |
| 16 | 	if err != nil { |
| 17 | 		r.terminalErr = err |
| 18 | -		if !r.finished { |
| 19 | +		if err == io.EOF && !r.finished { |
| 20 | 			r.clearDeadlineLocked() |
| 21 | 		} |
| 22 | 	} |
| 23 | --- a/vendor/github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy/reverseproxy.go |
| 24 | +++ b/vendor/github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy/reverseproxy.go |
| 25 | @@ -735,6 +735,10 @@ |
| 26 | 		// request, which is not our failure; don't retry or ding the upstream. |
| 27 | 		// Record a 499 (client closed request) so the access log reflects the |
| 28 | 		// disconnect instead of a misleading 0 status (see #7396). |
| 29 | +		// Cancellation can leave body bytes queued on a still-open client socket. |
| 30 | +		if origReq.ProtoMajor == 1 { |
| 31 | +			w.Header().Set("Connection", "close") |
| 32 | +		} |
| 33 | 		w.WriteHeader(499) |
| 34 | 		return true, nil |
| 35 | 	} |