summaryrefslogtreecommitdiffhomepage
path: root/test/node
diff options
context:
space:
mode:
Diffstat (limited to 'test/node')
-rwxr-xr-xtest/node/404/app.js3
-rwxr-xr-xtest/node/basic/app.js4
-rwxr-xr-xtest/node/double_end/app.js3
-rwxr-xr-xtest/node/mirror/app.js4
-rwxr-xr-xtest/node/promise_handler/app.js3
-rwxr-xr-xtest/node/status_message/app.js3
-rwxr-xr-xtest/node/variables/app.js3
-rwxr-xr-xtest/node/websockets/mirror/app.js31
-rwxr-xr-xtest/node/websockets/mirror_fragmentation/app.js26
-rwxr-xr-xtest/node/write_before_write_head/app.js3
-rwxr-xr-xtest/node/write_buffer/app.js4
-rwxr-xr-xtest/node/write_return/app.js4
12 files changed, 71 insertions, 20 deletions
diff --git a/test/node/404/app.js b/test/node/404/app.js
index 9600d486..587c432d 100755
--- a/test/node/404/app.js
+++ b/test/node/404/app.js
@@ -3,6 +3,5 @@
var fs = require('fs');
require('unit-http').createServer(function (req, res) {
- res.writeHead(404, {});
- res.end(fs.readFileSync('404.html'));
+ res.writeHead(404, {}).end(fs.readFileSync('404.html'));
}).listen(7080);
diff --git a/test/node/basic/app.js b/test/node/basic/app.js
index bc8d570a..7820c474 100755
--- a/test/node/basic/app.js
+++ b/test/node/basic/app.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node
require('unit-http').createServer(function (req, res) {
- res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'});
- res.end('Hello World\n');
+ res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'})
+ .end('Hello World\n');
}).listen(7080);
diff --git a/test/node/double_end/app.js b/test/node/double_end/app.js
index d8280917..63912097 100755
--- a/test/node/double_end/app.js
+++ b/test/node/double_end/app.js
@@ -1,6 +1,5 @@
#!/usr/bin/env node
require('unit-http').createServer(function (req, res) {
- res.end();
- res.end();
+ res.end().end();
}).listen(7080);
diff --git a/test/node/mirror/app.js b/test/node/mirror/app.js
index abcb87cb..1488917e 100755
--- a/test/node/mirror/app.js
+++ b/test/node/mirror/app.js
@@ -6,7 +6,7 @@ require('unit-http').createServer(function (req, res) {
body += chunk.toString();
});
req.on('end', () => {
- res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
- res.end(body);
+ res.writeHead(200, {'Content-Length': Buffer.byteLength(body)})
+ .end(body);
});
}).listen(7080);
diff --git a/test/node/promise_handler/app.js b/test/node/promise_handler/app.js
index 60b0c3bb..51c3666b 100755
--- a/test/node/promise_handler/app.js
+++ b/test/node/promise_handler/app.js
@@ -6,8 +6,7 @@ require('unit-http').createServer(function (req, res) {
res.end();
if (req.headers['x-write-call']) {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.write('blah');
+ res.writeHead(200, {'Content-Type': 'text/plain'}).write('blah');
}
Promise.resolve().then(() => {
diff --git a/test/node/status_message/app.js b/test/node/status_message/app.js
index 4f3b064a..e8a798dd 100755
--- a/test/node/status_message/app.js
+++ b/test/node/status_message/app.js
@@ -1,6 +1,5 @@
#!/usr/bin/env node
require('unit-http').createServer(function (req, res) {
- res.writeHead(200, 'blah', {'Content-Type': 'text/plain'});
- res.end();
+ res.writeHead(200, 'blah', {'Content-Type': 'text/plain'}).end();
}).listen(7080);
diff --git a/test/node/variables/app.js b/test/node/variables/app.js
index 4ed94d09..d8cdc20c 100755
--- a/test/node/variables/app.js
+++ b/test/node/variables/app.js
@@ -14,7 +14,6 @@ require('unit-http').createServer(function (req, res) {
res.setHeader('Content-Type', req.headers['content-type']);
res.setHeader('Custom-Header', req.headers['custom-header']);
res.setHeader('Http-Host', req.headers['host']);
- res.writeHead(200, {});
- res.end(body);
+ res.writeHead(200, {}).end(body);
});
}).listen(7080);
diff --git a/test/node/websockets/mirror/app.js b/test/node/websockets/mirror/app.js
new file mode 100755
index 00000000..23746465
--- /dev/null
+++ b/test/node/websockets/mirror/app.js
@@ -0,0 +1,31 @@
+#!/usr/bin/env node
+
+server = require('unit-http').createServer(function() {});
+webSocketServer = require('unit-http/websocket').server;
+//server = require('http').createServer(function() {});
+//webSocketServer = require('websocket').server;
+
+server.listen(7080, function() {});
+
+var wsServer = new webSocketServer({
+ maxReceivedMessageSize: 0x1000000000,
+ maxReceivedFrameSize: 0x1000000000,
+ fragmentOutgoingMessages: false,
+ fragmentationThreshold: 0x1000000000,
+ httpServer: server,
+});
+
+wsServer.on('request', function(request) {
+ var connection = request.accept(null);
+
+ connection.on('message', function(message) {
+ if (message.type === 'utf8') {
+ connection.send(message.utf8Data);
+ } else if (message.type === 'binary') {
+ connection.send(message.binaryData);
+ }
+
+ });
+
+ connection.on('close', function(r) {});
+});
diff --git a/test/node/websockets/mirror_fragmentation/app.js b/test/node/websockets/mirror_fragmentation/app.js
new file mode 100755
index 00000000..7024252a
--- /dev/null
+++ b/test/node/websockets/mirror_fragmentation/app.js
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+
+server = require('unit-http').createServer(function() {});
+webSocketServer = require('unit-http/websocket').server;
+//server = require('http').createServer(function() {});
+//webSocketServer = require('websocket').server;
+
+server.listen(7080, function() {});
+
+var wsServer = new webSocketServer({
+ httpServer: server
+});
+
+wsServer.on('request', function(request) {
+ //console.log('request');
+ var connection = request.accept(null);
+
+ connection.on('message', function(message) {
+ //console.log('message');
+ connection.send(message.utf8Data);
+ });
+
+ connection.on('close', function(r) {
+ //console.log('close');
+ });
+});
diff --git a/test/node/write_before_write_head/app.js b/test/node/write_before_write_head/app.js
index 6e3fb9a9..724b0efb 100755
--- a/test/node/write_before_write_head/app.js
+++ b/test/node/write_before_write_head/app.js
@@ -2,6 +2,5 @@
require('unit-http').createServer(function (req, res) {
res.write('blah');
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.end();
+ res.writeHead(200, {'Content-Type': 'text/plain'}).end();
}).listen(7080);
diff --git a/test/node/write_buffer/app.js b/test/node/write_buffer/app.js
index f41de2a1..a7623523 100755
--- a/test/node/write_buffer/app.js
+++ b/test/node/write_buffer/app.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node
require('unit-http').createServer(function (req, res) {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.end(new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]));
+ res.writeHead(200, {'Content-Type': 'text/plain'})
+ .end(new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]));
}).listen(7080);
diff --git a/test/node/write_return/app.js b/test/node/write_return/app.js
index 3ae967c6..82dfbc6e 100755
--- a/test/node/write_return/app.js
+++ b/test/node/write_return/app.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node
require('unit-http').createServer(function (req, res) {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.end(res.write('body').toString());
+ res.writeHead(200, {'Content-Type': 'text/plain'})
+ .end(res.write('body').toString());
}).listen(7080);