Improve vfsgen to not unzip bindata files but send to browser directly (#7109)
* Don't unzip files from bindata but send to browser directly * remove dependent for httpgzip * Add tests for parseAcceptEncoding * Update docs for ENABLE_GZIP * Fix bug * Fix bug Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
87a0396719
commit
19ae6439b0
7 changed files with 105 additions and 5 deletions
|
@ -87,6 +87,16 @@ func (opts *Options) staticHandler(dir string) func(next http.Handler) http.Hand
|
|||
}
|
||||
}
|
||||
|
||||
// parseAcceptEncoding parse Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5 as compress methods
|
||||
func parseAcceptEncoding(val string) map[string]bool {
|
||||
parts := strings.Split(val, ";")
|
||||
var types = make(map[string]bool)
|
||||
for _, v := range strings.Split(parts[0], ",") {
|
||||
types[strings.TrimSpace(v)] = true
|
||||
}
|
||||
return types
|
||||
}
|
||||
|
||||
func (opts *Options) handle(w http.ResponseWriter, req *http.Request, opt *Options) bool {
|
||||
if req.Method != "GET" && req.Method != "HEAD" {
|
||||
return false
|
||||
|
@ -157,6 +167,6 @@ func (opts *Options) handle(w http.ResponseWriter, req *http.Request, opt *Optio
|
|||
return true
|
||||
}
|
||||
|
||||
http.ServeContent(w, req, file, fi.ModTime(), f)
|
||||
ServeContent(w, req, fi, fi.ModTime(), f)
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue