From 24bd4e055562d8eb8a0d8db907c1715cc37e90b4 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 27 Jan 2015 23:02:40 +0100 Subject: [PATCH] test: add http upgrade header regression test Add a regression test for https://github.com/iojs/io.js/issues/627. Before the http_parser rollback to 2.3.0, the request callback was called but an 'upgrade' event was not emitted, even though there is an Upgrade header present in the request. PR-URL: https://github.com/iojs/io.js/pull/628 Reviewed-By: Fedor Indutny --- test/parallel/test-http-upgrade-yes-please.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/parallel/test-http-upgrade-yes-please.js diff --git a/test/parallel/test-http-upgrade-yes-please.js b/test/parallel/test-http-upgrade-yes-please.js new file mode 100644 index 0000000000..d9e5dc6eca --- /dev/null +++ b/test/parallel/test-http-upgrade-yes-please.js @@ -0,0 +1,22 @@ +'use strict'; + +var assert = require('assert'); +var http = require('http'); +var net = require('net'); + +var upgrades = 0; +process.on('exit', function() { assert.equal(upgrades, 1); }); + +http.createServer(assert.fail).listen(0, '127.0.0.1', function() { + this.on('upgrade', function(req, conn, head) { + conn.destroy(); + this.close(); + upgrades += 1; + }); + var options = { host: this.address().address, port: this.address().port }; + net.connect(options, function() { + this.write('GET / HTTP/1.1\r\n' + + 'Upgrade: Yes, please.\r\n' + + '\r\n'); + }); +});