(use http-client) (define *s* (make-string 2048)) (define (read/write length outport) (let loop ((size length)) (let* ((bytes (min 1024 size))) (unless (zero? size) (write-string *s* bytes outport) (loop (- size bytes)))))) (define (download-enclosure url length dest) (let* ((target-location (string-append dest "/tempfile")) (temp-file (string-append target-location ".part")) (outport (open-output-file temp-file))) #;(read/write length outport) ; No bug (with-input-from-request url #f (lambda () (read/write length outport))) ; bug (when (file-exists? temp-file) (print " done.") (rename-file temp-file target-location)))) (download-enclosure "http://alternativlos.cdn.as250.net/alternativlos-17.mp3" 89885440 "/tmp")