mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-03 07:18:12 +08:00
* http api: send header even when r is not ready yet. fixes #3304 License: MIT Signed-off-by: Jan Winkelmann <j-winkelmann@tuhh.de> * http api: check flush error and only flush once per iteration License: MIT Signed-off-by: Jan Winkelmann <j-winkelmann@tuhh.de> * http api: f.Flush is not in fact returning anything License: MIT Signed-off-by: Jan Winkelmann <j-winkelmann@tuhh.de> * api http: remove pointless Flush License: MIT Signed-off-by: Jan Winkelmann <j-winkelmann@tuhh.de>
This commit is contained in:
parent
01ea333751
commit
68d8a298c5
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user