[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mysterious gzipped images
From: |
Stefan Monnier |
Subject: |
Re: Mysterious gzipped images |
Date: |
Wed, 07 Aug 2013 10:35:54 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> address@hidden /tmp]$ curl -O
> https://icons.duckduckgo.com/i/a-z-animals.com.ico
> address@hidden /tmp]$ file a-z-animals.com.ico
> a-z-animals.com.ico: gzip compressed data, max compression
[...]
> So it's a gzipped image! After unzipping Emacs understands it
> perfectly.
So curl doesn't implement Accept/Content-Encoding either? That's weird!
>> I think it would be useful to have built-in libz support in Emacs. When
>> fetching lots of small image files (which is quite common), I think that
>> calling inflate() would be a lot faster than calling the gunzip command
>> over pipes. Probably. Should I go ahead and implement this?
> Erm, I went ahead and implemented it. Should I just check in? :-)
Sounds good, tho I'd prefer to see the patch first.
Stefan "Wondering if that could be used to decompress the index
at the end of PDF files as well"
PS: Here's my previous hack for URL.
=== modified file 'lisp/url/url-http.el'
--- lisp/url/url-http.el 2013-07-22 04:06:21 +0000
+++ lisp/url/url-http.el 2013-07-22 15:45:14 +0000
@@ -313,10 +313,8 @@
(if url-personal-mail-address
(concat
"From: " url-personal-mail-address "\r\n"))
- ;; Encodings we understand
- (if url-mime-encoding-string
- (concat
- "Accept-encoding: " url-mime-encoding-string "\r\n"))
+ ;; Encodings we understand. FIXME: Only use gzip if installed.
+ "Accept-encoding: gzip\r\n"
(if url-mime-charset-string
(concat
"Accept-charset: " url-mime-charset-string "\r\n"))
@@ -544,7 +542,16 @@
;; mark it as successful.
(widen)
(if (and url-automatic-caching (equal url-http-method "GET"))
- (url-store-in-cache buffer))))
+ (url-store-in-cache buffer))
+ ;; Decompress, if needed. Do it after storing the result in
+ ;; the cache, so the cache keeps the compressed data.
+ (when (mail-fetch-field "Content-Encoding")
+ ;; The only encoding we support.
+ (cl-assert (equal "gzip" (mail-fetch-field "Content-Encoding")))
+ (save-excursion
+ (goto-char (point-min))
+ (re-search-forward "^\n")
+ (call-process-region (point) (point-max) "gzip" t t nil "-d")))))
(setq success t))
(3 ; Redirection
;; 300 Multiple choices
- Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/06
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/06
- Re: Mysterious gzipped images, Andreas Schwab, 2013/08/06
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/06
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/06
- Re: Mysterious gzipped images, Julien Danjou, 2013/08/07
- Re: Mysterious gzipped images,
Stefan Monnier <=
- Re: Mysterious gzipped images, chad, 2013/08/07
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/08
- Re: Mysterious gzipped images, Andreas Schwab, 2013/08/08
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/11
- Re: Mysterious gzipped images, Paul Eggert, 2013/08/08
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/08
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/08
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/11
- Re: Mysterious gzipped images, Romain Francoise, 2013/08/08
- Re: Mysterious gzipped images, Lars Magne Ingebrigtsen, 2013/08/08