From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Bogatov Newsgroups: gmane.lisp.guile.user Subject: Re: Downloading a file from a URL from the web with http-get Date: Tue, 5 Aug 2014 11:45:35 +0400 Organization: Church of GNU Message-ID: <20140805074535.GA6232@self.lan> References: <956cfbf0-ab9a-434f-bf45-14872a5084f6@email.android.com> <20140804165757.GA32158@self.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9amGYk9869ThD9tj" X-Trace: ger.gmane.org 1407224792 18699 80.91.229.3 (5 Aug 2014 07:46:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Aug 2014 07:46:32 +0000 (UTC) Cc: guile-user@gnu.org To: =?utf-8?B?55m954aK?= Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Aug 05 09:46:27 2014 Return-path: Envelope-to: guile-user@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 1XEZRt-0001Mp-Op for guile-user@m.gmane.org; Tue, 05 Aug 2014 09:46:21 +0200 Original-Received: from localhost ([::1]:57544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEZRt-0005ox-7X for guile-user@m.gmane.org; Tue, 05 Aug 2014 03:46:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEZRg-0005or-Bd for guile-user@gnu.org; Tue, 05 Aug 2014 03:46:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEZRb-0002TX-LC for guile-user@gnu.org; Tue, 05 Aug 2014 03:46:08 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEZRb-0002TT-Ht for guile-user@gnu.org; Tue, 05 Aug 2014 03:46:03 -0400 Original-Received: from tor-exit-node.dnslab.nl ([95.211.229.158]:54208 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1XEZRa-0002vx-4D; Tue, 05 Aug 2014 03:46:03 -0400 Content-Disposition: inline In-Reply-To: X-Haskell-Quote: IO String contains a String in the same way that /bin/ls contains a list of files X-Perfect-World: There should be one -- and preferably only one -- obvious way to do it. User-Agent: Mutt/1.5.22.1 (2013-10-16) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11370 Archived-At: --9amGYk9869ThD9tj Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * =E7=99=BD=E7=86=8A [2014-08-05 03:56:03+04= 00] > Also, is there a way to determine the exact file size, so I could > check before downloading, if the file has already been downloaded, > i.e. same size on disk as on the web, or if the prior download failed, > i.e. smaller size on disk, than the web? > > I thought the headers would have the size info of the tarball, but I see = no such information in res-headers... > > But surely, the information must be available as any download tool > like wget or a browser is able to determine the download file size. Seems that wget also do not have this information. wget -S http://hackage.haskell.org/package/HaTeX-2.1.3/HaTeX-2.1.3.tar.gz --2014-08-05 11:27:59-- http://hackage.haskell.org/package/HaTeX-2.1.3/HaT= eX-2.1.3.tar.gz Resolving hackage.haskell.org (hackage.haskell.org)... 88.198.224.242, 88.1= 98.224.242 Connecting to hackage.haskell.org (hackage.haskell.org)|88.198.224.242|:80.= =2E. connected. HTTP request sent, awaiting response... HTTP/1.1 200 OK Server: nginx/1.6.0 Date: Mon, 04 Aug 2014 16:53:31 GMT Content-Type: application/x-gzip Content-MD5: c4d3cf03316068d1ef0799024f6a1dfd ETag: "c4d3cf03316068d1ef0799024f6a1dfd" Last-Modified: Fri, 22 Oct 2010 21:18:12 GMT Age: 52477 Transfer-Encoding: chunked Connection: keep-alive Length: unspecified [application/x-gzip] Saving to: `HaTeX-2.1.3.tar.gz' Look, it says, that length is unspecified. My best bet is use #:streaming? flag to `http-get` to examine headers before downloading, and = if I decide to download, get data from port via `get-bytevector` function family. This way you also can examine first several bytes before decide, whether file is needed, if headers information is not sufficient. -- Best regards, Dmitry Bogatov , Free Software supporter, esperantisto and netiquette guardian. GPG: 54B7F00D --9amGYk9869ThD9tj Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJT4IufAAoJEHiL4BJUt/AN5pMP/ja7ckC8BiIKtyfia6KrU8Gr iID1UjSaciG8yL1+vUaKXTd5k7+WrLJjq3j6e0VfTf6Z8AU7dz7zh36G29bWxuPO babWuRB7mUPITfSvVhdK8kMGLP2n8obFjWtQNQ4wUEW/CFHhuJ2aOHtcUN6rR1Vf hLZmwIVWTTj8Kxl4gIo75RVpBu7vH7rcxAy1MnG16lj3x8PyAB18TsUfe6Qx8UOS RjcVWPiNsxdUlOp63YwjKsarCLLmzF62Uis0D7rT5yUvDeCnx44DgKuhHqobupsz dG3H9SMfTSWZujJvoWuNw1eAwc+G2vn3CQCjGiX1kCl1AT94FHJQPGGuU/uHVueO GH/S8sTiwZTnlQ4o0zSK/CneHALJYlkXXgMC1vOkOgrLVIx3xiHZvg0/1BXByLG4 5cK0iwLtu1lJIhHDPrXHnrMks6hFXnxSh6kFpw/iuN31NzfvWJG+l4WsMTzJ5HHJ O9KzgL09vAT79/RNu+uSC2RSD3/JezhGQE1APtzctwhQ6o3B8pes5hNBdP7upfi9 ZNQx0BzqzbXKDlxR73VkMCN+pqS2zaMN3aFltrN53ZQYPQamWu0Bpl8DP5MnucPc t9NEgJV97RHYr99nnD7PNrW4facl/sYquEeqHGnralKTOtpT4LEXclsFzi8jk7qA iDWqUm6W+1sAm60hmbxp =n8YD -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--