summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-flush-response-headers.js
diff options
context:
space:
mode:
authorVladimir Kurchatkin <vladimir.kurchatkin@gmail.com>2015-05-13 18:52:49 +0300
committerVladimir Kurchatkin <vladimir.kurchatkin@gmail.com>2015-05-29 16:19:12 +0300
commit2c686fd3ce4b68a1d7955da9c157baf52ab25285 (patch)
treead549c466d608e25c4d25f7f34a7f15754d7ee4a /test/parallel/test-http-flush-response-headers.js
parent4e90c82cdb9d69dbffe340e7ac9bd1b4b6e1d781 (diff)
downloadandroid-node-v8-2c686fd3ce4b68a1d7955da9c157baf52ab25285.tar.gz
android-node-v8-2c686fd3ce4b68a1d7955da9c157baf52ab25285.tar.bz2
android-node-v8-2c686fd3ce4b68a1d7955da9c157baf52ab25285.zip
http: flush stored header
`flushHeaders` should work for header written with `writeHead`. PR-URL: https://github.com/nodejs/io.js/pull/1695 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/parallel/test-http-flush-response-headers.js')
-rw-r--r--test/parallel/test-http-flush-response-headers.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/parallel/test-http-flush-response-headers.js b/test/parallel/test-http-flush-response-headers.js
new file mode 100644
index 0000000000..76e739741c
--- /dev/null
+++ b/test/parallel/test-http-flush-response-headers.js
@@ -0,0 +1,27 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+
+const server = http.createServer();
+
+server.on('request', function(req, res) {
+ res.writeHead(200, {'foo': 'bar'});
+ res.flushHeaders();
+ res.flushHeaders(); // Should be idempotent.
+});
+server.listen(common.PORT, common.localhostIPv4, function() {
+ var req = http.request({
+ method: 'GET',
+ host: common.localhostIPv4,
+ port: common.PORT,
+ }, onResponse);
+
+ req.end();
+
+ function onResponse(res) {
+ assert.equal(res.headers['foo'], 'bar');
+ res.destroy();
+ server.close();
+ }
+});