mirror of
https://github.com/arnaucube/comunicationLeap.git
synced 2026-02-07 03:16:45 +01:00
nodejs with express server, leapmotion for movement control, and threejs for 3d render
This commit is contained in:
27
node_modules/formidable/test/standalone/test-connection-aborted.js
generated
vendored
Normal file
27
node_modules/formidable/test/standalone/test-connection-aborted.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var assert = require('assert');
|
||||
var http = require('http');
|
||||
var net = require('net');
|
||||
var formidable = require('../../lib/index');
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
var form = new formidable.IncomingForm();
|
||||
var aborted_received = false;
|
||||
form.on('aborted', function () {
|
||||
aborted_received = true;
|
||||
});
|
||||
form.on('error', function () {
|
||||
assert(aborted_received, 'Error event should follow aborted');
|
||||
server.close();
|
||||
});
|
||||
form.on('end', function () {
|
||||
throw new Error('Unexpected "end" event');
|
||||
});
|
||||
form.parse(req);
|
||||
}).listen(0, 'localhost', function () {
|
||||
var client = net.connect(server.address().port);
|
||||
client.write(
|
||||
"POST / HTTP/1.1\r\n" +
|
||||
"Content-Length: 70\r\n" +
|
||||
"Content-Type: multipart/form-data; boundary=foo\r\n\r\n");
|
||||
client.end();
|
||||
});
|
||||
48
node_modules/formidable/test/standalone/test-content-transfer-encoding.js
generated
vendored
Normal file
48
node_modules/formidable/test/standalone/test-content-transfer-encoding.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
var assert = require('assert');
|
||||
var common = require('../common');
|
||||
var formidable = require('../../lib/index');
|
||||
var http = require('http');
|
||||
|
||||
var server = http.createServer(function(req, res) {
|
||||
var form = new formidable.IncomingForm();
|
||||
form.uploadDir = common.dir.tmp;
|
||||
form.on('end', function () {
|
||||
throw new Error('Unexpected "end" event');
|
||||
});
|
||||
form.on('error', function (e) {
|
||||
res.writeHead(500);
|
||||
res.end(e.message);
|
||||
});
|
||||
form.parse(req);
|
||||
});
|
||||
|
||||
server.listen(0, function() {
|
||||
var body =
|
||||
'--foo\r\n' +
|
||||
'Content-Disposition: form-data; name="file1"; filename="file1"\r\n' +
|
||||
'Content-Type: application/octet-stream\r\n' +
|
||||
'\r\nThis is the first file\r\n' +
|
||||
'--foo\r\n' +
|
||||
'Content-Type: application/octet-stream\r\n' +
|
||||
'Content-Disposition: form-data; name="file2"; filename="file2"\r\n' +
|
||||
'Content-Transfer-Encoding: unknown\r\n' +
|
||||
'\r\nThis is the second file\r\n' +
|
||||
'--foo--\r\n';
|
||||
|
||||
var req = http.request({
|
||||
method: 'POST',
|
||||
port: server.address().port,
|
||||
headers: {
|
||||
'Content-Length': body.length,
|
||||
'Content-Type': 'multipart/form-data; boundary=foo'
|
||||
}
|
||||
});
|
||||
req.on('response', function (res) {
|
||||
assert.equal(res.statusCode, 500);
|
||||
res.on('data', function () {});
|
||||
res.on('end', function () {
|
||||
server.close();
|
||||
});
|
||||
});
|
||||
req.end(body);
|
||||
});
|
||||
49
node_modules/formidable/test/standalone/test-issue-46.js
generated
vendored
Normal file
49
node_modules/formidable/test/standalone/test-issue-46.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
var http = require('http'),
|
||||
formidable = require('../../lib/index'),
|
||||
request = require('request'),
|
||||
assert = require('assert');
|
||||
|
||||
var host = 'localhost';
|
||||
|
||||
var index = [
|
||||
'<form action="/" method="post" enctype="multipart/form-data">',
|
||||
' <input type="text" name="foo" />',
|
||||
' <input type="submit" />',
|
||||
'</form>'
|
||||
].join("\n");
|
||||
|
||||
var server = http.createServer(function(req, res) {
|
||||
|
||||
// Show a form for testing purposes.
|
||||
if (req.method == 'GET') {
|
||||
res.writeHead(200, {'content-type': 'text/html'});
|
||||
res.end(index);
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse form and write results to response.
|
||||
var form = new formidable.IncomingForm();
|
||||
form.parse(req, function(err, fields, files) {
|
||||
res.writeHead(200, {'content-type': 'text/plain'});
|
||||
res.write(JSON.stringify({err: err, fields: fields, files: files}));
|
||||
res.end();
|
||||
});
|
||||
|
||||
}).listen(0, host, function() {
|
||||
|
||||
console.log("Server up and running...");
|
||||
|
||||
var server = this,
|
||||
url = 'http://' + host + ':' + server.address().port;
|
||||
|
||||
var parts = [
|
||||
{'Content-Disposition': 'form-data; name="foo"', 'body': 'bar'}
|
||||
]
|
||||
|
||||
var req = request({method: 'POST', url: url, multipart: parts}, function(e, res, body) {
|
||||
var obj = JSON.parse(body);
|
||||
assert.equal("bar", obj.fields.foo);
|
||||
server.close();
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user