Browse Source

don't set mime type to text/plain. This will break serving e.g. raw images,
html, etc

According to http://golang.org/pkg/net/http/#DetectContentType
"If the Header does not contain a Content-Type line, Write adds
a Content-Type set to the result of passing the initial 512 bytes
of written data to DetectContentType."

Don Bowman 10 năm trước cách đây
mục cha
commit
423b1c69be
1 tập tin đã thay đổi với 0 bổ sung1 xóa
  1. 0 1
      routers/repo/download.go

+ 0 - 1
routers/repo/download.go

@@ -27,7 +27,6 @@ func ServeBlob(ctx *middleware.Context, blob *git.Blob) error {
 
 
 	_, isTextFile := base.IsTextFile(buf)
 	_, isTextFile := base.IsTextFile(buf)
 	_, isImageFile := base.IsImageFile(buf)
 	_, isImageFile := base.IsImageFile(buf)
-	ctx.Resp.Header().Set("Content-Type", "text/plain")
 	if !isTextFile && !isImageFile {
 	if !isTextFile && !isImageFile {
 		ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+path.Base(ctx.Repo.TreeName))
 		ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+path.Base(ctx.Repo.TreeName))
 		ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary")
 		ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary")