Skip to content

Commit

Permalink
Skip status code 105 on Node > v10
Browse files Browse the repository at this point in the history
  • Loading branch information
simov committed May 15, 2018
1 parent d555bd7 commit 0c5db42
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions tests/test-gzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,28 +270,23 @@ tape('do not try to pipe HEAD request responses', function (t) {
tape('do not try to pipe responses with no body', function (t) {
var options = { url: server.url + '/foo', gzip: true }

options.headers = {code: 105}
request.post(options, function (err, res, body) {
t.equal(err, null)
t.equal(res.headers.code, '105')
t.equal(body, '')
// skip 105 on Node >= v10
var statusCodes = process.version.split('.')[0].slice(1) >= 10
? [204, 304] : [105, 204, 304]

options.headers = {code: 204}
;(function next (index) {
if (index === statusCodes.length) {
t.end()
return
}
options.headers = {code: statusCodes[index]}
request.post(options, function (err, res, body) {
t.equal(err, null)
t.equal(res.headers.code, '204')
t.equal(res.headers.code, statusCodes[index].toString())
t.equal(body, '')

options.headers = {code: 304}
request.post(options, function (err, res, body) {
t.equal(err, null)
t.equal(res.headers.code, '304')
t.equal(body, '')

t.end()
})
next(++index)
})
})
})(0)
})

tape('cleanup', function (t) {
Expand Down

0 comments on commit 0c5db42

Please sign in to comment.