mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
ipn/localapi: only flush relevant data in multiFilePostResponseWriter.Flush()
This prevents two things: 1. Crashing if there's no response body 2. Sending a nonsensical 0 response status code Updates tailscale/corp#22357 Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:
parent
a15ff1bade
commit
74b9fa1348
@ -1752,11 +1752,18 @@ func (ww *multiFilePostResponseWriter) Write(p []byte) (int, error) {
|
||||
}
|
||||
|
||||
func (ww *multiFilePostResponseWriter) Flush(w http.ResponseWriter) error {
|
||||
maps.Copy(w.Header(), ww.Header())
|
||||
if ww.header != nil {
|
||||
maps.Copy(w.Header(), ww.header)
|
||||
}
|
||||
if ww.statusCode > 0 {
|
||||
w.WriteHeader(ww.statusCode)
|
||||
}
|
||||
if ww.body != nil {
|
||||
_, err := io.Copy(w, ww.body)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) singleFilePut(
|
||||
ctx context.Context,
|
||||
|
Loading…
Reference in New Issue
Block a user