From 9dcabc145f0d565b5219e2fd72c3da04876980b7 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 9 Feb 2018 21:24:22 -0500 Subject: [PATCH] fixed incorrect content-type when using file middleware --- file/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/file/server.go b/file/server.go index 7de6359..62637ac 100644 --- a/file/server.go +++ b/file/server.go @@ -113,6 +113,7 @@ func Server(pathMap PathMap, opts ...ServerOptions) routing.Handler { return serveFile(c, dir, filepath.Join(path, options.IndexFile)) } + c.Response.Header().Del("Content-Type") http.ServeContent(c.Response, c.Request, path, fstat.ModTime(), file) return nil } @@ -130,6 +131,7 @@ func serveFile(c *routing.Context, dir http.Dir, path string) error { } else if fstat.IsDir() { return routing.NewHTTPError(http.StatusNotFound) } + c.Response.Header().Del("Content-Type") http.ServeContent(c.Response, c.Request, path, fstat.ModTime(), file) return nil } @@ -157,6 +159,7 @@ func Content(path string) routing.Handler { } else if fstat.IsDir() { return routing.NewHTTPError(http.StatusNotFound) } + c.Response.Header().Del("Content-Type") http.ServeContent(c.Response, c.Request, path, fstat.ModTime(), file) return nil }