aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPip Cet2019-07-25 13:22:15 +0000
committerEli Zaretskii2019-07-27 13:54:04 +0300
commite310843d9dc106187d0e45ef7f0b9cd90a881eec (patch)
treed60df45275047bd65a05f1e6e116b8148aef2eac
parent02bb676a0547e0a25fc697d3a4c539e5415b90be (diff)
downloademacs-e310843d9dc106187d0e45ef7f0b9cd90a881eec.tar.gz
emacs-e310843d9dc106187d0e45ef7f0b9cd90a881eec.zip
Don't double-decompress cached HTTP responses (bug#36773)
* lisp/url/url-http.el (url-handle-content-transfer-encoding): Modify the message headers as well as the message body to reflect decompression. * lisp/mail/mail-utils.el (mail-fetch-field): Add DELETE argument, to delete header lines included in the result.
-rw-r--r--lisp/mail/mail-utils.el13
-rw-r--r--lisp/url/url-http.el2
2 files changed, 11 insertions, 4 deletions
diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el
index cbcbdfaeb2e..fd00dd19bc2 100644
--- a/lisp/mail/mail-utils.el
+++ b/lisp/mail/mail-utils.el
@@ -284,11 +284,13 @@ comma-separated list, and return the pruned list."
284 284
285 285
286;;;###autoload 286;;;###autoload
287(defun mail-fetch-field (field-name &optional last all list) 287(defun mail-fetch-field (field-name &optional last all list delete)
288 "Return the value of the header field whose type is FIELD-NAME. 288 "Return the value of the header field whose type is FIELD-NAME.
289If second arg LAST is non-nil, use the last field of type FIELD-NAME. 289If second arg LAST is non-nil, use the last field of type FIELD-NAME.
290If third arg ALL is non-nil, concatenate all such fields with commas between. 290If third arg ALL is non-nil, concatenate all such fields with commas between.
291If 4th arg LIST is non-nil, return a list of all such fields. 291If 4th arg LIST is non-nil, return a list of all such fields.
292If 5th arg DELETE is non-nil, delete all header lines that are
293included in the result.
292The buffer should be narrowed to just the header, else false 294The buffer should be narrowed to just the header, else false
293matches may be returned from the message body." 295matches may be returned from the message body."
294 (save-excursion 296 (save-excursion
@@ -311,7 +313,9 @@ matches may be returned from the message body."
311 (setq value (concat value 313 (setq value (concat value
312 (if (string= value "") "" ", ") 314 (if (string= value "") "" ", ")
313 (buffer-substring-no-properties 315 (buffer-substring-no-properties
314 opoint (point))))))) 316 opoint (point)))))
317 (if delete
318 (delete-region (point-at-bol) (point)))))
315 (if list 319 (if list
316 value 320 value
317 (and (not (string= value "")) value))) 321 (and (not (string= value "")) value)))
@@ -324,7 +328,10 @@ matches may be returned from the message body."
324 ;; Back up over newline, then trailing spaces or tabs 328 ;; Back up over newline, then trailing spaces or tabs
325 (forward-char -1) 329 (forward-char -1)
326 (skip-chars-backward " \t" opoint) 330 (skip-chars-backward " \t" opoint)
327 (buffer-substring-no-properties opoint (point))))))))) 331 (prog1
332 (buffer-substring-no-properties opoint (point))
333 (if delete
334 (delete-region (point-at-bol) (1+ (point))))))))))))
328 335
329;; Parse a list of tokens separated by commas. 336;; Parse a list of tokens separated by commas.
330;; It runs from point to the end of the visible part of the buffer. 337;; It runs from point to the end of the visible part of the buffer.
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index f7f2f3d179d..838f0a30c1f 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -959,7 +959,7 @@ should be shown to the user."
959 (start end &optional allow-partial)) 959 (start end &optional allow-partial))
960 960
961(defun url-handle-content-transfer-encoding () 961(defun url-handle-content-transfer-encoding ()
962 (let ((encoding (mail-fetch-field "content-encoding"))) 962 (let ((encoding (mail-fetch-field "content-encoding" nil nil nil t)))
963 (when (and encoding 963 (when (and encoding
964 (fboundp 'zlib-available-p) 964 (fboundp 'zlib-available-p)
965 (zlib-available-p) 965 (zlib-available-p)