1
var assert = require('assert');
2
var common = require('../common');
3
var formidable = require('../../lib/index');
4
var http = require('http');
6
var server = http.createServer(function(req, res) {
7
var form = new formidable.IncomingForm();
8
form.uploadDir = common.dir.tmp;
9
form.on('end', function () {
10
throw new Error('Unexpected "end" event');
12
form.on('error', function (e) {
19
server.listen(0, function() {
22
'Content-Disposition: form-data; name="file1"; filename="file1"\r\n' +
23
'Content-Type: application/octet-stream\r\n' +
24
'\r\nThis is the first file\r\n' +
26
'Content-Type: application/octet-stream\r\n' +
27
'Content-Disposition: form-data; name="file2"; filename="file2"\r\n' +
28
'Content-Transfer-Encoding: unknown\r\n' +
29
'\r\nThis is the second file\r\n' +
32
var req = http.request({
34
port: server.address().port,
36
'Content-Length': body.length,
37
'Content-Type': 'multipart/form-data; boundary=foo'
40
req.on('response', function (res) {
41
assert.equal(res.statusCode, 500);
42
res.on('data', function () {});
43
res.on('end', function () {