Skip to content

Commit be75470

Browse files
committed
http api: check flush error and only flush once per iteration
1 parent 3de98f1 commit be75470

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

commands/http/handler.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ func flushCopy(w io.Writer, r io.Reader) error {
299299
}
300300
for {
301301
// flush to send header when r is not ready yet
302-
f.Flush()
302+
err = f.Flush()
303+
if err != nil {
304+
return err
305+
}
303306

304307
n, err := r.Read(buf)
305308
switch err {
@@ -323,8 +326,6 @@ func flushCopy(w io.Writer, r io.Reader) error {
323326
if nw != n {
324327
return fmt.Errorf("http write failed to write full amount: %d != %d", nw, n)
325328
}
326-
327-
f.Flush()
328329
}
329330
return nil
330331
}

0 commit comments

Comments
 (0)