From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Mysterious gzipped images Date: Wed, 07 Aug 2013 10:35:54 -0400 Message-ID: References: <87mwoul8sz.fsf@igel.home> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1375886179 15032 80.91.229.3 (7 Aug 2013 14:36:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 Aug 2013 14:36:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Lars Magne Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 07 16:36:21 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V74qb-0004zB-3p for ged-emacs-devel@m.gmane.org; Wed, 07 Aug 2013 16:36:21 +0200 Original-Received: from localhost ([::1]:51394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V74qa-0004eQ-L6 for ged-emacs-devel@m.gmane.org; Wed, 07 Aug 2013 10:36:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V74qR-0004Vp-CH for emacs-devel@gnu.org; Wed, 07 Aug 2013 10:36:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V74qC-0004Cx-8Z for emacs-devel@gnu.org; Wed, 07 Aug 2013 10:36:11 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:49734) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V74qB-0004Cg-RS for emacs-devel@gnu.org; Wed, 07 Aug 2013 10:35:56 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFLd/Nq/2dsb2JhbABEvw4Xc4IeAQEEAVYjEAsVHxIUGA0kiB4GDMEdBI0fg2sDpHqBXoMTgVM X-IPAS-Result: Av4EABK/CFFLd/Nq/2dsb2JhbABEvw4Xc4IeAQEEAVYjEAsVHxIUGA0kiB4GDMEdBI0fg2sDpHqBXoMTgVM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="20804501" Original-Received: from 75-119-243-106.dsl.teksavvy.com (HELO pastel.home) ([75.119.243.106]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 07 Aug 2013 10:35:48 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 82E4E66AF2; Wed, 7 Aug 2013 10:35:54 -0400 (EDT) In-Reply-To: (Lars Magne Ingebrigtsen's message of "Wed, 07 Aug 2013 03:08:45 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:162462 Archived-At: > [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