]> git.eshelyaron.com Git - emacs.git/commitdiff
Add Content-Transfer gzip support to url
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Sun, 11 Aug 2013 20:52:50 +0000 (22:52 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Sun, 11 Aug 2013 20:52:50 +0000 (22:52 +0200)
* url-http.el (url-handle-content-transfer-encoding): Support
decompressing gzipped content.

* url-vars.el (url-mime-encoding-string): If we have built-in gzip
support, say that we accept gzipped content.

lisp/url/ChangeLog
lisp/url/url-http.el
lisp/url/url-vars.el

index 120d00002e4bd257f531b806c29606617d35d9ea..9bdaff6f51a21c1d154987f78982d3e9c3cadd94 100644 (file)
@@ -1,3 +1,11 @@
+2013-08-11  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * url-vars.el (url-mime-encoding-string): If we have built-in gzip
+       support, say that we accept gzipped content.
+
+       * url-http.el (url-handle-content-transfer-encoding): Support
+       decompressing gzipped content.
+
 2013-07-31  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * url-handlers.el (url-file-name-completion)
index 7f21a38c5355dbc2782ebbe33d0acdb6d5b86457..beffbe1f79b20da17ab3c7e346cf3e4127e51e44 100644 (file)
@@ -851,11 +851,23 @@ should be shown to the user."
        (error "Unknown class of HTTP response code: %d (%d)"
              class url-http-response-status)))
     (if (not success)
-       (url-mark-buffer-as-dead buffer))
+       (url-mark-buffer-as-dead buffer)
+      (url-handle-content-transfer-encoding))
     (url-http-debug "Finished parsing HTTP headers: %S" success)
     (widen)
     success))
 
+(defun url-handle-content-transfer-encoding ()
+  (let ((encoding (mail-fetch-field "content-encoding")))
+    (when (and encoding
+              (fboundp 'decompress-gzipped-region)
+              (equal (downcase encoding) "gzip"))
+      (save-restriction
+       (widen)
+       (goto-char (point-min))
+       (when (search-forward "\n\n")
+         (decompress-gzipped-region (point) (point-max)))))))
+
 ;; Miscellaneous
 (defun url-http-activate-callback ()
   "Activate callback specified when this buffer was created."
index 6cd0e9aec3c51cef523792216093c65288a682cc..a59667b57b04554e4ff1929292284212d78f7cf0 100644 (file)
@@ -210,8 +210,8 @@ Should be an assoc list of headers/contents.")
 
 (defvar url-request-method nil "The method to use for the next request.")
 
-;; FIXME!!  (RFC 2616 gives examples like `compress, gzip'.)
-(defvar url-mime-encoding-string nil
+(defvar url-mime-encoding-string (and (fboundp 'decompress-gzipped-region)
+                                     "gzip")
   "String to send in the Accept-encoding: field in HTTP requests.")
 
 (defvar mm-mime-mule-charset-alist)