From 4206c1f7a833a54e13dab318abd332a4fb35d067 Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Wed, 24 Jul 2019 13:23:50 +0000 Subject: [PATCH 2/2] Cache HTTP responses as uncompressed data. * lisp/url/url-http.el (url-http-parse-headers): Decompress before storing URL buffers in the cache. --- lisp/url/url-http.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 527760118d..d282b166e9 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -589,6 +589,7 @@ url-http-parse-headers (let* ((buffer (current-buffer)) (class (/ url-http-response-status 100)) (success nil) + (nodecompress nil) ;; other status symbols: jewelry and luxury cars (status-symbol (cadr (assq url-http-response-status url-http-codes)))) (url-http-debug "Parsed HTTP headers: class=%d status=%d" @@ -628,8 +629,10 @@ url-http-parse-headers ;; Generic success for all others. Store in the cache, and ;; mark it as successful. (widen) - (if (and url-automatic-caching (equal url-http-method "GET")) - (url-store-in-cache buffer)))) + (when (and url-automatic-caching (equal url-http-method "GET")) + (setq nodecompress t) + (url-handle-content-transfer-encoding) + (url-store-in-cache buffer)))) (setq success t)) (3 ; Redirection ;; 300 Multiple choices @@ -677,7 +680,8 @@ url-http-parse-headers (url-cache-create-filename (url-view-url t))) (url-cache-extract (url-cache-create-filename (url-view-url t))) (setq redirect-uri nil - success t)) + success t + nodecompress t)) ('use-proxy ; 305 ;; The requested resource MUST be accessed through the ;; proxy given by the Location field. The Location field @@ -941,7 +945,8 @@ url-http-parse-headers class url-http-response-status))) (if (not success) (url-mark-buffer-as-dead buffer) - (url-handle-content-transfer-encoding)) + (if (not nodecompress) + (url-handle-content-transfer-encoding))) (url-http-debug "Finished parsing HTTP headers: %S" success) (widen) (goto-char (point-min)) -- 2.22.0