From 3a3a0cf8a7be9205341f3cd3f086c523ecd9ebb7 Mon Sep 17 00:00:00 2001 From: Lisa Kim Date: Fri, 29 Jul 2022 10:47:35 -0700 Subject: [PATCH] Return nil on success for web UI file tranfers (#15021) When we download, we write the file contents with the `http.ResponseWriter` which is also used to write our replies, so it was also writing our success replies. fixes https://github.com/gravitational/teleport/issues/14557 --- lib/web/files.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/web/files.go b/lib/web/files.go index d603ecea0c6..db711871cab 100644 --- a/lib/web/files.go +++ b/lib/web/files.go @@ -79,7 +79,9 @@ func (h *Handler) transferFile(w http.ResponseWriter, r *http.Request, p httprou return nil, trace.Wrap(err) } - return OK(), nil + // We must return nil so that we don't write anything to + // the response, which would corrupt the downloaded file. + return nil, nil } type fileTransfer struct {