unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: Mysterious gzipped images
Date: Wed, 07 Aug 2013 10:35:54 -0400	[thread overview]
Message-ID: <jwvfvul7esl.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <m3eha6joiq.fsf@stories.gnus.org> (Lars Magne Ingebrigtsen's message of "Wed, 07 Aug 2013 03:08:45 +0200")

> [larsi@stories /tmp]$ curl -O https://icons.duckduckgo.com/i/a-z-animals.com.ico
> [larsi@stories /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




  parent reply	other threads:[~2013-08-07 14:35 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 22:20 Mysterious gzipped images Lars Magne Ingebrigtsen
2013-08-06 22:30 ` Lars Magne Ingebrigtsen
2013-08-06 23:05   ` Andreas Schwab
2013-08-06 23:38     ` Lars Magne Ingebrigtsen
2013-08-07  1:08       ` Lars Magne Ingebrigtsen
2013-08-07  8:51         ` Julien Danjou
2013-08-07 14:35         ` Stefan Monnier [this message]
2013-08-07 16:47           ` chad
2013-08-08 10:35           ` Lars Magne Ingebrigtsen
2013-08-08 10:57             ` Andreas Schwab
2013-08-11 19:44               ` Lars Magne Ingebrigtsen
2013-08-08 13:22             ` Paul Eggert
2013-08-08 14:06               ` Lars Magne Ingebrigtsen
2013-08-08 15:31                 ` Lars Magne Ingebrigtsen
2013-08-11 22:05                   ` Lars Magne Ingebrigtsen
2013-08-08 13:24             ` Romain Francoise
2013-08-08 13:28               ` Lars Magne Ingebrigtsen
2013-08-08 13:36                 ` Christopher Schmidt
2013-08-08 13:55                   ` Lars Magne Ingebrigtsen
2013-08-08 14:06                     ` Christopher Schmidt
2013-08-08 14:09                       ` Lars Magne Ingebrigtsen
2013-08-08 15:43                 ` Romain Francoise
2013-08-08 15:52                   ` Lars Magne Ingebrigtsen
2013-08-11 19:51                   ` Lars Magne Ingebrigtsen
2013-08-08 14:47             ` Stefan Monnier
2013-08-11 19:47               ` Lars Magne Ingebrigtsen
2013-08-12  0:54                 ` Stefan Monnier
2013-08-12 14:05                   ` Lars Magne Ingebrigtsen
2013-08-12 15:09                     ` Stefan Monnier
2013-08-12 15:20                     ` Eli Zaretskii
2013-08-12 16:27                       ` Lars Magne Ingebrigtsen
2013-08-12 16:42                         ` Eli Zaretskii
2013-08-12 12:13                 ` Eli Zaretskii
2013-08-12 12:21                   ` Eli Zaretskii
2013-08-12 13:06                     ` Lars Magne Ingebrigtsen
2013-08-12 13:29                       ` Eli Zaretskii
2013-08-13 23:40                       ` Lars Magne Ingebrigtsen
2013-08-14 13:09                         ` Lars Magne Ingebrigtsen
2013-08-14 15:12                           ` Eli Zaretskii
2013-08-17 15:01                             ` Lars Magne Ingebrigtsen
2013-08-17 15:27                               ` Eli Zaretskii
2013-08-17 17:04                                 ` Eli Zaretskii
2013-08-18 17:06                                   ` Lars Magne Ingebrigtsen
2013-08-07 18:25         ` Rüdiger Sonderfeld
2013-08-07 21:06           ` FFI (was: Mysterious gzipped images) Stefan Monnier
2013-08-08  0:50             ` Stephen J. Turnbull

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvfvul7esl.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).