guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Downloading a file from a URL from the web with http-get


From: Dmitry Bogatov
Subject: Re: Downloading a file from a URL from the web with http-get
Date: Tue, 5 Aug 2014 11:45:35 +0400
User-agent: Mutt/1.5.22.1 (2013-10-16)

* 白熊 <address@hidden> [2014-08-05 03:56:03+0400]
> 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/HaTeX-2.1.3.tar.gz
Resolving hackage.haskell.org (hackage.haskell.org)... 88.198.224.242, 
88.198.224.242
Connecting to hackage.haskell.org (hackage.haskell.org)|88.198.224.242|:80... 
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 <address@hidden>,
Free Software supporter, esperantisto and netiquette guardian.
GPG: 54B7F00D

Attachment: pgpMOeSHD27hg.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]