summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-response-writehead-returns-this.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-http-response-writehead-returns-this.js')
-rw-r--r--test/parallel/test-http-response-writehead-returns-this.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/parallel/test-http-response-writehead-returns-this.js b/test/parallel/test-http-response-writehead-returns-this.js
new file mode 100644
index 0000000000..a62c2eca03
--- /dev/null
+++ b/test/parallel/test-http-response-writehead-returns-this.js
@@ -0,0 +1,22 @@
+'use strict';
+require('../common');
+const http = require('http');
+const assert = require('assert');
+
+const server = http.createServer((req, res) => {
+ res.writeHead(200, { 'a-header': 'a-header-value' }).end('abc');
+});
+
+server.listen(0, () => {
+ http.get({ port: server.address().port }, (res) => {
+ assert.strictEqual(res.headers['a-header'], 'a-header-value');
+
+ const chunks = [];
+
+ res.on('data', (chunk) => chunks.push(chunk));
+ res.on('end', () => {
+ assert.strictEqual(Buffer.concat(chunks).toString(), 'abc');
+ server.close();
+ });
+ });
+});