From 527cabefcb874659cc796873b05eea9bf10a3d9e Mon Sep 17 00:00:00 2001 From: Alexis Campailla Date: Fri, 24 Jan 2014 07:03:10 -0800 Subject: [PATCH] test: fix connection reset in http test In this test, an HTTP server was ending the response before consuming all the data sent in the PUT request. Ending the response would cause the socket to be destroyed, and since there is some data still to be read, an ECONNRESET is surfaced on the client side, event though the client has already ended its side and even seen a 'finish' event. See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.2 While it is certainly admissible for the server to send a response before consuming the entire request, it seems reasonable to expect that the server would close the connection afterwards and that the ECONNRESET would be raised on the client. So I have changed the test to wait until the entire request has been consumed before sending the response. --- test/simple/test-http-outgoing-finish.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/simple/test-http-outgoing-finish.js b/test/simple/test-http-outgoing-finish.js index 7acea07c99..30a0119247 100644 --- a/test/simple/test-http-outgoing-finish.js +++ b/test/simple/test-http-outgoing-finish.js @@ -25,8 +25,10 @@ var assert = require('assert'); var http = require('http'); http.createServer(function(req, res) { - write(res); req.resume(); + req.on('end', function() { + write(res); + }); this.close(); }).listen(common.PORT, function() { var req = http.request({