s3: answer ClientDisconnected for a GET the client aborted before the first byte (#12707)

* s3: answer ClientDisconnected for a GET the client aborted before the first byte

Fixes #12706

* s3: tell a gone client on TLS and HTTP/2 too, and not on a connection the server closed
This commit is contained in:
Konstantin Adzer authored and GitHub committed 2026-11-17 17:15:00 -08:00
1 parent c91da3d1f8
commit 91eaabf371
4 files changed
+117 -9

No files matched your search

+6 -1
View File
@@ -293,7 +293,8 @@ func isCanceledStreamingError(err error) bool {
// wrote a response. A canceled error is answered too: the idle timeout and a
// shared lookup canceled by another request both cancel it while the client is
// still connected, and returning silently would send that client an empty 200.
// A client that has gone away never sees the write.
// A client that has gone away never sees the write; it is answered
// ClientDisconnected so that an aborted download does not count as a 5xx.
func writeStreamErrorResponse(w http.ResponseWriter, r *http.Request, err error) {
var streamErr *StreamError
if errors.As(err, &streamErr) && streamErr.ResponseWritten {
@@ -303,6 +304,10 @@ func writeStreamErrorResponse(w http.ResponseWriter, r *http.Request, err error)
s3err.WriteErrorResponse(w, r, s3err.ErrRequestBytesExceed)
return
}
if isCanceledStreamingError(err) && util.ClientGone(r.Context()) {
s3err.WriteErrorResponse(w, r, s3err.ErrClientDisconnected)
return
}
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)
}