Skip to content

Commit

Permalink
http api: check flush error and only flush once per iteration
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jan Winkelmann <j-winkelmann@tuhh.de>
  • Loading branch information
keks committed Oct 15, 2016
1 parent 3de98f1 commit ca6c167
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions commands/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ func flushCopy(w io.Writer, r io.Reader) error {
}
for {
// flush to send header when r is not ready yet
f.Flush()
err = f.Flush()
if err != nil {
return err
}

n, err := r.Read(buf)
switch err {
Expand All @@ -323,8 +326,6 @@ func flushCopy(w io.Writer, r io.Reader) error {
if nw != n {
return fmt.Errorf("http write failed to write full amount: %d != %d", nw, n)
}

f.Flush()
}
return nil
}
Expand Down

0 comments on commit ca6c167

Please sign in to comment.