Browse Source

handle gzip for image resizing

pull/1287/head
Chris Lu 5 years ago
parent
commit
fee3319cbf
  1. 8
      weed/server/volume_server_handlers_read.go

8
weed/server/volume_server_handlers_read.go

@ -145,7 +145,13 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
if ext != ".gz" { if ext != ".gz" {
if n.IsGzipped() { if n.IsGzipped() {
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
w.Header().Set("Content-Encoding", "gzip")
if _, _, _, shouldResize := shouldResizeImages(ext, r); shouldResize {
if n.Data, err = util.UnGzipData(n.Data); err != nil {
glog.V(0).Infoln("ungzip error:", err, r.URL.Path)
}
} else {
w.Header().Set("Content-Encoding", "gzip")
}
} else { } else {
if n.Data, err = util.UnGzipData(n.Data); err != nil { if n.Data, err = util.UnGzipData(n.Data); err != nil {
glog.V(0).Infoln("ungzip error:", err, r.URL.Path) glog.V(0).Infoln("ungzip error:", err, r.URL.Path)

Loading…
Cancel
Save