Skip to content

Commit

Permalink
tests: add req pipeline test
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Jan 4, 2019
1 parent 10a4081 commit d3c21c0
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,43 @@ describe('onFinished(req, listener)', function () {
})
})

describe('when requests pipelined', function () {
it('should handle socket errors', function (done) {
var count = 0
var server = http.createServer(function (req) {
var num = ++count

onFinished(req, function (err) {
assert.ok(err)
if (!--wait) server.close(done)
})

if (num === 1) {
// second request
writeRequest(socket, true)
req.pause()
} else {
// cause framing error in second request
socket.write('W')
req.resume()
}
})
var socket
var wait = 3

server.listen(function () {
socket = net.connect(this.address().port, function () {
writeRequest(this)
})

socket.on('close', function () {
assert.strictEqual(count, 2)
if (!--wait) server.close(done)
})
})
})
})

describe('when the request aborts', function () {
it('should execute the callback', function (done) {
var client
Expand Down

0 comments on commit d3c21c0

Please sign in to comment.