Browse Source

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.
v0.11.12-release
Alexis Campailla 11 years ago
committed by Timothy J Fontaine
parent
commit
527cabefcb
  1. 4
      test/simple/test-http-outgoing-finish.js

4
test/simple/test-http-outgoing-finish.js

@ -25,8 +25,10 @@ var assert = require('assert');
var http = require('http'); var http = require('http');
http.createServer(function(req, res) { http.createServer(function(req, res) {
write(res);
req.resume(); req.resume();
req.on('end', function() {
write(res);
});
this.close(); this.close();
}).listen(common.PORT, function() { }).listen(common.PORT, function() {
var req = http.request({ var req = http.request({

Loading…
Cancel
Save