USING: accessors assocs continuations http http.client http.client.private io.encodings.binary kernel math.parser sequences splitting ; IN: http-part : ( url from-bytes to-bytes -- request ) [ ] 2dip [ number>string ] bi@ "-" glue "bytes=" prepend "Range" set-header ; : ( url #bytes -- request ) 0 swap ; : safer-http-request ( request -- response/f data/empty ) [ http-request ] [ nip dup download-failed? [ response>> f ] [ drop f f ] if ] recover "" or ; : http-safe-get ( url -- response/f data/f ) safer-http-request ; : http-partial-get ( url #bytes -- response data/f ) safer-http-request ; : http-encoding ( url -- encoding/f ) 0 http-partial-get drop dup [ content-encoding>> ] when ; : valid-page? ( url -- ? ) 0 http-partial-get nip >boolean ; : http-binary? ( url -- ? ) http-encoding binary? ; : http-size ( url -- n ) 0 http-partial-get drop header>> "content-range" swap at "/" split1-last nip string>number ; : grab-http-chunk ( url from-bytes to-bytes -- response data ) safer-http-request ;