Commit 6d3fb6c0 authored by keks's avatar keks Committed by Jeromy Johnson

http api: makes sure header is sent even when r is not ready yet. fixes #3304 (#3305)

* http api: send header even when r is not ready yet. fixes #3304

License: MIT
Signed-off-by: default avatarJan Winkelmann <j-winkelmann@tuhh.de>

* http api: check flush error and only flush once per iteration

License: MIT
Signed-off-by: default avatarJan Winkelmann <j-winkelmann@tuhh.de>

* http api: f.Flush is not in fact returning anything

License: MIT
Signed-off-by: default avatarJan Winkelmann <j-winkelmann@tuhh.de>

* api http: remove pointless Flush

License: MIT
Signed-off-by: default avatarJan Winkelmann <j-winkelmann@tuhh.de>
parent ccd507ea
......@@ -288,6 +288,7 @@ func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req
log.Error("err: ", err)
w.Header().Set(StreamErrHeader, sanitizedErrStr(err))
}
}
func flushCopy(w io.Writer, r io.Reader) error {
......@@ -298,6 +299,9 @@ func flushCopy(w io.Writer, r io.Reader) error {
return err
}
for {
// flush to send header when r is not ready yet
f.Flush()
n, err := r.Read(buf)
switch err {
case io.EOF:
......@@ -320,8 +324,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
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment