Fix header writing
This commit is contained in:
@@ -94,6 +94,7 @@
|
||||
"discord_webhook_url": "https://discord.com/api/webhooks/...",
|
||||
"webdav": {
|
||||
"torrents_refresh_interval": "5m",
|
||||
"download_links_refresh_interval": "1h"
|
||||
"download_links_refresh_interval": "1h",
|
||||
"rc_url": "http://192.168.0.219:9990"
|
||||
}
|
||||
}
|
||||
@@ -289,15 +289,16 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
for k, v := range responseRecorder.Header() {
|
||||
w.Header()[k] = v
|
||||
}
|
||||
w.WriteHeader(responseRecorder.Code)
|
||||
|
||||
if acceptsGzip(r) {
|
||||
w.Header().Set("Content-Encoding", "gzip")
|
||||
w.Header().Set("Vary", "Accept-Encoding")
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(gzippedData)))
|
||||
w.WriteHeader(responseRecorder.Code)
|
||||
w.Write(gzippedData)
|
||||
} else {
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(responseData)))
|
||||
w.WriteHeader(responseRecorder.Code)
|
||||
w.Write(responseData)
|
||||
}
|
||||
return
|
||||
@@ -416,9 +417,11 @@ func (h *Handler) serveFromCacheIfValid(w http.ResponseWriter, r *http.Request,
|
||||
w.Header().Set("Content-Encoding", "gzip")
|
||||
w.Header().Set("Vary", "Accept-Encoding")
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(respCache.GzippedData)))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(respCache.GzippedData)
|
||||
} else {
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(respCache.Data)))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(respCache.Data)
|
||||
}
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user