@@ -10,11 +10,12 @@ import (
10
10
"compress/gzip"
11
11
"io"
12
12
"io/ioutil"
13
- "log"
14
13
"mime"
15
14
"net/http"
16
15
"path/filepath"
17
16
"time"
17
+
18
+ "code.gitea.io/gitea/modules/log"
18
19
)
19
20
20
21
// Static implements the macaron static handler for serving assets.
@@ -60,9 +61,9 @@ func AssetIsDir(name string) (bool, error) {
60
61
func ServeContent (w http.ResponseWriter , req * http.Request , name string , modtime time.Time , content io.ReadSeeker ) {
61
62
encodings := parseAcceptEncoding (req .Header .Get ("Accept-Encoding" ))
62
63
if encodings ["gzip" ] {
63
- if rd , ok := f .(* vfsgen۰CompressedFile ); ok {
64
+ if rd , ok := content .(* vfsgen۰CompressedFile ); ok {
64
65
w .Header ().Set ("Content-Encoding" , "gzip" )
65
- ctype := mime .TypeByExtension (filepath .Ext (fi . Name () ))
66
+ ctype := mime .TypeByExtension (filepath .Ext (name ))
66
67
if ctype == "" {
67
68
// read a chunk to decide between utf-8 text and binary
68
69
var buf [512 ]byte
@@ -71,16 +72,17 @@ func ServeContent(w http.ResponseWriter, req *http.Request, name string, modtime
71
72
ctype = http .DetectContentType (buf [:n ])
72
73
_ , err := rd .Seek (0 , io .SeekStart ) // rewind to output whole file
73
74
if err != nil {
74
- log .Printf ("rd.Seek error: %v\n " , err )
75
- return false
75
+ log .Error ("rd.Seek error: %v" , err )
76
+ http .Error (w , http .StatusText (500 ), 500 )
77
+ return
76
78
}
77
79
}
78
80
w .Header ().Set ("Content-Type" , ctype )
79
- http .ServeContent (w , req , file , fi . ModTime () , rd )
80
- return true
81
+ http .ServeContent (w , req , name , modtime , rd )
82
+ return
81
83
}
82
84
}
83
85
84
- http .ServeContent (w , req , file , fi . ModTime (), f )
85
- return true
86
+ http .ServeContent (w , req , name , modtime , content )
87
+ return
86
88
}
0 commit comments