Commit c6186982 authored by Jan Winkelmann's avatar Jan Winkelmann

revert commit breaking ipfs add for js-ipfs-api

Revert "http api: makes sure header is sent even when r is not ready yet. fixes #3304 (#3305)"
This reverts commit 68d8a298.

License: MIT
Signed-off-by: default avatarJan Winkelmann <j-winkelmann@tuhh.de>
parent 6779ff10
...@@ -288,7 +288,6 @@ func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req ...@@ -288,7 +288,6 @@ func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req
log.Error("err: ", err) log.Error("err: ", err)
w.Header().Set(StreamErrHeader, sanitizedErrStr(err)) w.Header().Set(StreamErrHeader, sanitizedErrStr(err))
} }
} }
func flushCopy(w io.Writer, r io.Reader) error { func flushCopy(w io.Writer, r io.Reader) error {
...@@ -299,9 +298,6 @@ func flushCopy(w io.Writer, r io.Reader) error { ...@@ -299,9 +298,6 @@ func flushCopy(w io.Writer, r io.Reader) error {
return err return err
} }
for { for {
// flush to send header when r is not ready yet
f.Flush()
n, err := r.Read(buf) n, err := r.Read(buf)
switch err { switch err {
case io.EOF: case io.EOF:
...@@ -324,6 +320,8 @@ func flushCopy(w io.Writer, r io.Reader) error { ...@@ -324,6 +320,8 @@ func flushCopy(w io.Writer, r io.Reader) error {
if nw != n { if nw != n {
return fmt.Errorf("http write failed to write full amount: %d != %d", nw, n) return fmt.Errorf("http write failed to write full amount: %d != %d", nw, n)
} }
f.Flush()
} }
return nil 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