From 60d6b8d7ee2cf6a82e84bac601f2dfe329893644 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 4 Jan 2018 10:09:12 -0800 Subject: [PATCH] don't sniff the filename to determine the content type fixes #4543, may break other things IMO, this is the best way to do this (for now, until we start manually storing the content type along with the files). I'd rather not guess at all but we can at least avoid guessing by filename. License: MIT Signed-off-by: Steven Allen --- core/corehttp/gateway_handler.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 9e0b8e1ec86..5d62ace8fce 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -261,14 +261,10 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr if !dir { urlFilename := r.URL.Query().Get("filename") - var name string if urlFilename != "" { w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename*=UTF-8''%s", url.PathEscape(urlFilename))) - name = urlFilename - } else { - name = gopath.Base(urlPath) } - i.serveFile(w, r, name, modtime, dr) + i.serveFile(w, r, modtime, dr) return } @@ -387,14 +383,14 @@ func (s *sizeSeeker) Seek(offset int64, whence int) (int64, error) { return s.sizeReadSeeker.Seek(offset, whence) } -func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) { +func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, modtime time.Time, content io.ReadSeeker) { if sp, ok := content.(sizeReadSeeker); ok { content = &sizeSeeker{ sizeReadSeeker: sp, } } - http.ServeContent(w, req, name, modtime, content) + http.ServeContent(w, req, "", modtime, content) } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) {