Skip to content

Commit

Permalink
test: add http upgrade header regression test
Browse files Browse the repository at this point in the history
Add a regression test for #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: #628
Reviewed-By: Fedor Indutny <[email protected]>
  • Loading branch information
bnoordhuis committed Jan 28, 2015
1 parent 6605096 commit 24bd4e0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/parallel/test-http-upgrade-yes-please.js
Original file line number Diff line number Diff line change
@@ -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');
});
});

0 comments on commit 24bd4e0

Please sign in to comment.