Browse Source

fix: don't flush if the request body hasn't been read entirely (#122)

Kévin Dunglas 2 years ago
parent
commit
4332bbe97c
1 changed files with 7 additions and 0 deletions
  1. 7 0
      frankenphp.go

+ 7 - 0
frankenphp.go

@@ -548,6 +548,13 @@ func go_sapi_flush(rh C.uintptr_t) bool {
 		return true
 	}
 
+	if r.ProtoMajor == 1 {
+		if _, err := r.Body.Read(nil); err != nil {
+			// Don't flush until the whole body has been read to prevent https://github.com/golang/go/issues/15527
+			return false
+		}
+	}
+
 	flusher.Flush()
 
 	return false