From 860568cb6c457a203157804569fcbb031313c75b Mon Sep 17 00:00:00 2001 From: JessonChan Date: Fri, 6 Nov 2015 18:51:53 +0800 Subject: [PATCH] modified as astaxie reviews https://github.com/astaxie/beego/pull/1376 --- config.go | 1 - memzipfile.go | 6 +++--- staticfile.go | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index c2f23f67..e8370f4f 100644 --- a/config.go +++ b/config.go @@ -529,7 +529,6 @@ func ParseConfig() (err error) { if ext == "" { continue } - ext = strings.ToLower(ext) if !strings.HasPrefix(ext, ".") { ext = "." + ext } diff --git a/memzipfile.go b/memzipfile.go index 594f1060..b61e87f2 100644 --- a/memzipfile.go +++ b/memzipfile.go @@ -206,9 +206,9 @@ func getAcceptEncodingZip(r *http.Request) string { ss = strings.ToLower(ss) if strings.Contains(ss, "gzip") { return "gzip" - } - if strings.Contains(ss, "deflate") { + } else if strings.Contains(ss, "deflate") { return "deflate" + } else { + return "" } - return "" } diff --git a/staticfile.go b/staticfile.go index e1fc4f73..de530b0c 100644 --- a/staticfile.go +++ b/staticfile.go @@ -96,9 +96,8 @@ func serverStaticRouter(ctx *context.Context) { } isStaticFileToCompress := false - lowerFileName := strings.ToLower(filePath) for _, statExtension := range StaticExtensionsToGzip { - if strings.HasSuffix(lowerFileName, statExtension) { + if strings.HasSuffix(strings.ToLower(filePath), strings.ToLower(statExtension)) { isStaticFileToCompress = true break }