add a multipart file upload captured from http.server, about to refactor multipart streams

db4
Doug Coleman 2008-11-21 22:56:40 -06:00
parent 5a4927de98
commit 8cc68ae5ee
2 changed files with 1242 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -27,11 +27,10 @@ TUPLE: multipart-stream stream n leftover separator ;
: multipart-split ( bytes separator -- before after seq=? )
2dup sequence= [ 2drop f f t ] [ split1 f ] if ;
PRIVATE>
:: multipart-step ( stream bytes end-stream? separator quot: ( bytes -- ) -- ? end-stream? )
#! return t to loop again
bytes separator multipart-split [ dup >boolean ] dip [
bytes separator multipart-split
[ dup >boolean ] dip [
! separator == input
3drop f quot call f
] [
@ -54,6 +53,8 @@ PRIVATE>
] if
] if stream leftover>> end-stream? not or ;
PRIVATE>
:: multipart-step-loop ( stream quot1: ( bytes -- ) quot2: ( -- ) -- ? )
stream dup [ read-n ] [ separator>> ] bi quot1 multipart-step
swap [ drop stream quot1 quot2 multipart-step-loop ] quot2 if ;