mime.multipart: use header, some cleanup.

db4
John Benediktsson 2015-04-17 17:41:56 -07:00
parent 24de8af6e5
commit b0ba4a5925
1 changed files with 9 additions and 7 deletions

View File

@ -1,10 +1,9 @@
! Copyright (C) 2009 Doug Coleman. ! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: multiline kernel sequences io splitting fry namespaces USING: accessors ascii assocs byte-arrays combinators fry
http.parsers hashtables assocs combinators ascii io.files.unique hashtables http http.parsers io io.encodings.binary io.files
accessors io.encodings.binary io.files byte-arrays math io.files.unique io.streams.string kernel math quoting sequences
io.streams.string combinators.short-circuit strings math.order splitting ;
quoting ;
IN: mime.multipart IN: mime.multipart
CONSTANT: buffer-size 65536 CONSTANT: buffer-size 65536
@ -20,7 +19,10 @@ name name-content
mime-parts ; mime-parts ;
TUPLE: mime-file headers filename temporary-path ; TUPLE: mime-file headers filename temporary-path ;
C: <mime-file> mime-file
TUPLE: mime-variable headers key value ; TUPLE: mime-variable headers key value ;
C: <mime-variable> mime-variable
: <multipart> ( mime-separator -- multipart ) : <multipart> ( mime-separator -- multipart )
multipart new multipart new
@ -80,7 +82,7 @@ ERROR: end-of-stream multipart ;
dup filename>> empty-name? [ dup filename>> empty-name? [
drop drop
] [ ] [
[ [ header>> ] [ filename>> ] [ temp-file>> ] tri mime-file boa ] [ [ header>> ] [ filename>> ] [ temp-file>> ] tri <mime-file> ]
[ content-disposition>> "name" of unquote ] [ content-disposition>> "name" of unquote ]
[ mime-parts>> set-at ] tri [ mime-parts>> set-at ] tri
] if ; ] if ;
@ -129,7 +131,7 @@ ERROR: unknown-content-disposition multipart ;
ERROR: no-content-disposition multipart ; ERROR: no-content-disposition multipart ;
: process-header ( multipart -- multipart ) : process-header ( multipart -- multipart )
"content-disposition" over header>> at ";" split1 swap { dup "content-disposition" header ";" split1 swap {
{ "form-data" [ { "form-data" [
parse-content-disposition-form-data >>content-disposition parse-content-disposition-form-data >>content-disposition
parse-form-data parse-form-data