Skip to content

Commit

Permalink
fixed incorrect content-type when using file middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxue committed Feb 10, 2018
1 parent 3b22ec8 commit 9dcabc1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions file/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9dcabc1

Please sign in to comment.