1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io.encodings.ascii io.files io.files.unique kernel
4 mime.multipart tools.test io.streams.duplex io multiline
6 IN: mime.multipart.tests
8 : upload-separator ( -- seq )
9 "----WebKitFormBoundary6odjpVPXIighAE2L" ;
12 "------WebKitFormBoundary6odjpVPXIighAE2L\r\nContent-Disposition: form-data; name=\"file1\"; filename=\"up.txt\"\r\nContent-Type: text/plain\r\n\r\nuploaded!\n\r\n------WebKitFormBoundary6odjpVPXIighAE2L\r\nContent-Disposition: form-data; name=\"file2\"; filename=\"\"\r\n\r\n\r\n------WebKitFormBoundary6odjpVPXIighAE2L\r\nContent-Disposition: form-data; name=\"file3\"; filename=\"\"\r\n\r\n\r\n------WebKitFormBoundary6odjpVPXIighAE2L\r\nContent-Disposition: form-data; name=\"text1\"\r\n\r\nlol\r\n------WebKitFormBoundary6odjpVPXIighAE2L--\r\n" ;
14 : mime-test-stream ( -- stream )
16 "mime" "test" make-unique-file ascii
17 [ set-file-contents ] [ <file-reader> ] 2bi ;
19 [ ] [ mime-test-stream [ ] with-input-stream ] unit-test
22 mime-test-stream [ upload-separator parse-multipart ] with-input-stream
23 nip "\"up.txt\"" swap key?
27 mime-test-stream [ upload-separator parse-multipart ] with-input-stream
28 drop "\"text1\"" swap key?