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.
This commit is contained in:
Alexis Campailla authored and Timothy J Fontaine committed 2014-02-13 16:46:04 -08:00
1 parent 3da36fe00e
commit 527cabefcb
1 file changed
+3 -1
+3 -1
View File
@@ -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({