From cd8f82c007bf316fcd857da1e00bfe358df7af44 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 4 May 2012 17:14:09 -0700 Subject: [PATCH] Fix incorrect merge choices --- lib/http.js | 22 +++++++++++++--------- test/gc/test-http-client-timeout.js | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/http.js b/lib/http.js index 5216abed2c..b8d3341627 100644 --- a/lib/http.js +++ b/lib/http.js @@ -116,8 +116,11 @@ function parserOnHeadersComplete(info) { function parserOnBody(b, start, len) { var parser = this; var slice = b.slice(start, start + len); - // body encoding is done in _emitData - parser.incoming._emitData(slice); + if (parser.incoming._paused || parser.incoming._pendings.length) { + parser.incoming._pendings.push(slice); + } else { + parser.incoming._emitData(slice); + } } function parserOnMessageComplete() { @@ -1263,7 +1266,7 @@ function freeParser(parser, req) { if (req) { req.parser = null; } -}; +} ClientRequest.prototype.onSocket = function(socket) { @@ -1376,13 +1379,16 @@ ClientRequest.prototype.onSocket = function(socket) { var closeListener = function() { debug('HTTP socket close'); + var req = socket._httpMessage; req.emit('close'); if (req.res && req.res.readable) { // Socket closed before we emitted 'end' below. req.res.emit('aborted'); + var res = req.res; req.res._emitPending(function() { - req.res._emitEnd(); - req.res.emit('close'); + res._emitEnd(); + res.emit('close'); + res = null; }); } else if (!req.res && !req._hadError) { // This socket error fired before we started to @@ -1532,10 +1538,8 @@ ClientRequest.prototype.setSocketKeepAlive = function() { this._deferToConnect('setKeepAlive', arguments); }; -ClientRequest.prototype.clearTimeout = function() { - var args = Array.prototype.slice.call(arguments, 0); - args.unshift(0); - this._deferToConnect('setTimeout', args); +ClientRequest.prototype.clearTimeout = function(cb) { + this.setTimeout(0, cb); }; exports.request = function(options, cb) { diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index c98a008a2c..cdf5019fc0 100644 --- a/test/gc/test-http-client-timeout.js +++ b/test/gc/test-http-client-timeout.js @@ -13,7 +13,7 @@ var http = require('http'), done = 0, count = 0, countGC = 0, - todo = 500, + todo = 400, common = require('../common.js'), assert = require('assert'), PORT = common.PORT;