From aa73ed973ca19963cc2c9591a77412598607b3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Tue, 5 Jan 2010 22:28:03 +0100 Subject: [PATCH] Added test case for the simple multipart API So far this didn't have any test coverage. --- test/mjsunit/test-multipart.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/mjsunit/test-multipart.js b/test/mjsunit/test-multipart.js index 93ab7ab0481..7a651790b6d 100644 --- a/test/mjsunit/test-multipart.js +++ b/test/mjsunit/test-multipart.js @@ -12,7 +12,7 @@ var badRequests = 0; var parts = {}; var respond = function(res, text) { requests++; - if (requests == 2) { + if (requests == 3) { server.close(); } @@ -22,6 +22,18 @@ var respond = function(res, text) { }; var server = http.createServer(function(req, res) { + if (req.headers['x-use-simple-api']) { + multipart.parse(req) + .addCallback(function() { + respond(res, 'thanks'); + }) + .addErrback(function() { + badRequests++; + }); + return; + } + + try { var stream = new multipart.Stream(req); } catch (e) { @@ -67,6 +79,11 @@ var request = client.request('POST', '/', {'Content-Type': 'multipart/form-data; request.sendBody(fixture.reply, 'binary'); request.finish(); +var client = http.createClient(port); +var simpleRequest = client.request('POST', '/', {'X-Use-Simple-Api': 'yes', 'Content-Type': 'multipart/form-data; boundary=AaB03x', 'Content-Length': fixture.reply.length}); +simpleRequest.sendBody(fixture.reply, 'binary'); +simpleRequest.finish(); + var badRequest = client.request('POST', '/', {'Content-Type': 'something', 'Content-Length': fixture.reply.length}); badRequest.sendBody(fixture.reply, 'binary'); badRequest.finish();