multipart.sjs (1064B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 function handleRequest(request, response) { 7 response.seizePower(); 8 9 response.write("HTTP/1.1 200 OK\r\n"); 10 response.write("Access-Control-Allow-Origin: *\r\n"); 11 // See bug 1752761. The extra "\r\n" was the reason why FormDataParser 12 // could not parse this correctly. 13 response.write( 14 "Content-type: multipart/form-data; boundary=boundary\r\n\r\n" 15 ); 16 response.write("\r\n"); 17 response.write("--boundary\r\n"); 18 response.write( 19 'Content-Disposition: form-data; name="file1"; filename="file1.txt"\r\n' 20 ); 21 response.write("Content-Type: text/plain\r\n\r\n"); 22 response.write("Content of file1\r\n"); 23 response.write("--boundary\r\n"); 24 response.write( 25 'Content-Disposition: form-data; name="file2"; filename="file2.txt"\r\n' 26 ); 27 response.write("Content-Type: text/plain\r\n\r\n"); 28 response.write("Content of file2\r\n"); 29 response.write("--boundary--\r\n"); 30 response.write(""); 31 response.finish(); 32 }