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: 白熊
Subject: Re: Downloading a file from a URL from the web with http-get
Date: Tue, 05 Aug 2014 03:56:03 +0400
User-agent: K-9 Mail for Android


On 2014年8月4日 20:57:57 GMT+04:00, Dmitry Bogatov <address@hidden> wrote:

>It seems that `http-get` do not manage SSL, and
>GNU site 302 to https version (or is it just my proxy config?)

Thank you, Dmitry. 

It seems to be your setup, as your code example works for me also on the GNU 
site. 

>So here is example for other url:
>
>       (use-modules ((web uri) #:select (string->uri))
>                    ((web client) #:select (http-get)))
>       (use-modules (rnrs io ports))
>
>       (define *url*
>         "http://hackage.haskell.org/package/HaTeX-2.1.3/HaTeX-2.1.3.tar.gz";)
>
>       (call-with-values
>           (lambda () (http-get (string->uri *url*)))
>         (lambda (res-headers res-body)
>           (with-output-to-file "some.tar.gz"
>             (lambda () (put-bytevector (current-output-port) res-body))
>             #:binary #t)))

Thank you for this, it's exactly what I was looking for. 

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. 

How can I do this? 
-- 
白熊




reply via email to

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