Adding http-get-to-file utility.

This commit is contained in:
Alex Shinn 2014-06-03 23:10:27 +09:00
parent a21e391f15
commit e88374275d
2 changed files with 11 additions and 1 deletions

View file

@ -264,6 +264,16 @@
(close-input-port p)
res)))
(define (http-get-to-file url path)
(call-with-input-url url
(lambda (in)
(let ((out (open-binary-output-file path)))
(let lp ()
(let ((c (read-u8 in)))
(cond ((not (eof-object? c))
(write-u8 c out)
(lp)))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; server utils

View file

@ -1,6 +1,6 @@
(define-library (chibi net http)
(export http-get http-get/headers
(export http-get http-get/headers http-get-to-file
http-head http-post http-put http-delete
call-with-input-url call-with-input-url/headers
with-input-from-url