fix: confirm header-only response delivery

This commit is contained in:
MiMoCode
2026-07-10 19:40:03 +08:00
parent 32988b6367
commit 62675e400b
3 changed files with 86 additions and 0 deletions
+13
View File
@@ -75,6 +75,19 @@ func (c *captureWriter) Flush() {
c.flush()
}
// ConfirmDelivery establishes an observable delivery boundary for responses
// whose headers were not followed by a body write.
func (c *captureWriter) ConfirmDelivery() {
if c.written != 0 {
return
}
if _, ok := c.ResponseWriter.(http.Flusher); !ok {
c.writeFailed = true
return
}
c.flush()
}
func (c *captureWriter) flush() {
if _, ok := c.ResponseWriter.(http.Flusher); !ok {
return