From 19c02063e9f99e96c413695850a5bc338a2959a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Fri, 22 Dec 2023 09:33:14 -0800 Subject: [PATCH] Make text/csv inline in the browser ... by using text/plain https://bugs.chromium.org/p/chromium/issues/detail?id=152911 --- server/history.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/history.go b/server/history.go index 9f8b385..1af999d 100644 --- a/server/history.go +++ b/server/history.go @@ -324,8 +324,10 @@ func (srv *Server) historyCSV(ctx context.Context, c echo.Context, history *logs // log.Info("entries", "count", len(history.LogScores), "out_bytes", b.Len()) - c.Request().Header.Set("Cache-Control", "s-maxage=120,max-age=120") - - return c.Blob(http.StatusOK, "text/csv", b.Bytes()) + c.Response().Header().Set("Cache-Control", "s-maxage=150,max-age=120") + c.Response().Header().Set("Content-Disposition", "inline") + // Chrome and Firefox force-download text/csv files, so use text/plain + // https://bugs.chromium.org/p/chromium/issues/detail?id=152911 + return c.Blob(http.StatusOK, "text/plain", b.Bytes()) }