@@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4545(define download:header #f) ; ;stores presence and type of header #f/200/300
4646(define download:tempfile (string-append (system-directory) (system-pathseparator) " download.tmp" ))
4747(define download:size 0)
48+ (define download:datastep 0)
4849
4950; ; Helper function to split return string into header and body
5051(define (download:split-headerbody str )
@@ -97,7 +98,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9798 (tempfile download:tempfile)
9899 (fh (open-output-file (list path: tempfile append: #t ))))
99100 (if download:header
100- (begin (write-subu8vector v 0 lv fh) (close-output-port fh))
101+ (begin (write-subu8vector v 0 lv fh) ( set! download:datalen ( + download:datalen lv)) (close-output-port fh))
101102 (begin (download:data-append! v)
102103 ; ;test for header presence
103104 (let* ((str (download:split-headerbody-vector download:data))
@@ -167,6 +168,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
167168 (ret (httpsclient-open host)))
168169 (set! download:header #f )
169170 (set! download:size 0 )
171+ (set! download:datastep 0 )
170172 (if (file-exists? download:tempfile) (delete-file download:tempfile))
171173 (if (> ret 0 )
172174 (let* ((request (string-append " GET " path " HTTP/1.0\r\n Host: " host " \r\n\r\n " ))
@@ -222,13 +224,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
222224 )
223225 )
224226 ))
225- (let ((count (httpsclient-recv download:buf)))
226- ; ; (if (or (string=? (system-platform) "android") (string=? (system-platform) "ios")) (thread-sleep! 0.001)) ;;allow GUI to refresh
227- (if (> count 0 )
228- (if usebuffer
229- (download:data-append-local! (subu8vector download:buf 0 count))
230- (download:data-append! (subu8vector download:buf 0 count))))
231- (loop count))
227+ (let ((count (httpsclient-recv download:buf)))
228+ (if (or (string=? (system-platform) " android" ) (string=? (system-platform) " ios" ))
229+ (let ((step (fix (/ download:datalen 1000000 ))))
230+ (if (fx> step download:datastep) (begin
231+ (set! download:datastep step)
232+ (thread-sleep! 0.001 )
233+ ))
234+ )) ; ;allow GUI to refresh on large files
235+ (if (> count 0 )
236+ (if usebuffer
237+ (download:data-append-local! (subu8vector download:buf 0 count))
238+ (download:data-append! (subu8vector download:buf 0 count))
239+ ))
240+ (loop count))
232241 )
233242 )
234243 )
0 commit comments