mirror of https://github.com/nodejs/node.git
Fix test-http-upgrade-server and test-http-parser
Problem was introduced in last http-parser upgrade which fixed a long standing bug with the upgrade event and removed several callbacks.
This commit is contained in:
parent
0df08c6a0c
commit
2126989a32
10
lib/http.js
10
lib/http.js
|
@ -1028,9 +1028,8 @@ function connectionListener(socket) {
|
|||
|
||||
var req = parser.incoming;
|
||||
|
||||
// This is start + byteParsed + 1 due to the error of getting \n
|
||||
// in the upgradeHead from the closing lines of the headers
|
||||
var upgradeHead = d.slice(start + bytesParsed + 1, end);
|
||||
// This is start + byteParsed
|
||||
var upgradeHead = d.slice(start + bytesParsed, end);
|
||||
|
||||
if (self.listeners('upgrade').length) {
|
||||
self.emit('upgrade', req, req.socket, upgradeHead);
|
||||
|
@ -1234,9 +1233,8 @@ Agent.prototype._establishNewConnection = function() {
|
|||
assert(socket._httpMessage);
|
||||
socket._httpMessage.res = res;
|
||||
|
||||
// This is start + byteParsed + 1 due to the error of getting \n
|
||||
// in the upgradeHead from the closing lines of the headers
|
||||
var upgradeHead = d.slice(start + bytesParsed + 1, end);
|
||||
// This is start + byteParsed
|
||||
var upgradeHead = d.slice(start + bytesParsed, end);
|
||||
|
||||
// Make sure we don't try to send HTTP requests to it.
|
||||
self._removeSocket(socket);
|
||||
|
|
10
lib/http2.js
10
lib/http2.js
|
@ -1104,9 +1104,8 @@ ClientRequest.prototype.onSocket = function(socket) {
|
|||
var res = parser.incoming;
|
||||
req.res = res;
|
||||
|
||||
// This is start + byteParsed + 1 due to the error of getting \n
|
||||
// in the upgradeHead from the closing lines of the headers
|
||||
var upgradeHead = d.slice(start + bytesParsed + 1, end);
|
||||
// This is start + byteParsed
|
||||
var upgradeHead = d.slice(start + bytesParsed, end);
|
||||
if (req.listeners('upgrade').length) {
|
||||
// Emit 'upgrade' on the Agent.
|
||||
req.upgraded = true;
|
||||
|
@ -1350,9 +1349,8 @@ function connectionListener(socket) {
|
|||
|
||||
var req = parser.incoming;
|
||||
|
||||
// This is start + byteParsed + 1 due to the error of getting \n
|
||||
// in the upgradeHead from the closing lines of the headers
|
||||
var upgradeHead = d.slice(start + bytesParsed + 1, end);
|
||||
// This is start + byteParsed
|
||||
var upgradeHead = d.slice(start + bytesParsed, end);
|
||||
|
||||
if (self.listeners('upgrade').length) {
|
||||
self.emit('upgrade', req, req.socket, upgradeHead);
|
||||
|
|
|
@ -58,16 +58,8 @@ parser.onURL = function(b, off, len) {
|
|||
callbacks++;
|
||||
};
|
||||
|
||||
parser.onPath = function(b, off, length) {
|
||||
console.log('path [' + off + ', ' + length + ']');
|
||||
var path = b.toString('ascii', off, off + length);
|
||||
console.log('path = "' + path + '"');
|
||||
assert.equal('/hello', path);
|
||||
callbacks++;
|
||||
};
|
||||
|
||||
parser.execute(buffer, 0, request.length);
|
||||
assert.equal(4, callbacks);
|
||||
assert.equal(3, callbacks);
|
||||
|
||||
//
|
||||
// Check that if we throw an error in the callbacks that error will be
|
||||
|
|
Loading…
Reference in New Issue