Hi everyone, I needed partial http get requests, and it wasn't in the
library
so I used http's range header.
this seems like a common need, so I'm sharing with you.
here's what I have so far:
: <partial-get-request> ( url #bytes -- request )
[ <get-request> ] dip number>string "bytes=0-" prepend "Range"
set-header ;
: http-partial-get ( url #bytes -- response data )
<partial-get-request> http-request ;
: http-encoding ( url -- encoding )
0 http-partial-get drop content-encoding>> ;
: 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 ;
: <partial-chunk> ( url from-bytes to-bytes -- request )
[ <get-request> ] 2dip [ number>string ] bi@ "-" glue "bytes="
prepend "Range" set-header ;
: grab-http-chunk ( url from-bytes to-bytes -- response data )
<partial-chunk> http-request ;
best regards, kobi
--
China: stop persecuting Falun Gong!
http://faluninfo.net
URGENT: Innocent people are being persecuted for their belief inside Communist
China.
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk