summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-08-06 16:24:11 +0300
committerValentin Bartenev <vbart@nginx.com>2019-08-06 16:24:11 +0300
commit7fd9444728e1e509630f5ba0f50e7f9da150369c (patch)
tree2d6c898e0508f9df7e8367eaa64072fedd2c92ac /test
parentc7210eaa5a15083715cac574cce055b94860e70e (diff)
downloadunit-7fd9444728e1e509630f5ba0f50e7f9da150369c.tar.gz
unit-7fd9444728e1e509630f5ba0f50e7f9da150369c.tar.bz2
Node.js: returning "this" from writeHead() to allow chaining.
In Node.js version 11.10.0 and later, the writeHead() function returns "this".
Diffstat (limited to '')
-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/write_before_write_head/app.js3
-rwxr-xr-xtest/node/write_buffer/app.js4
-rwxr-xr-xtest/node/write_return/app.js4
10 files changed, 14 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/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);