Skip to content

Commit

Permalink
Merge pull request JakeChampion#534 from remcohaszing/response-undefi…
Browse files Browse the repository at this point in the history
…ned-status

Allow undefined Response status
  • Loading branch information
mislav authored Jun 19, 2017
2 parents 9a0c992 + 0ecdd40 commit 27473e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
}

this.type = 'default'
this.status = 'status' in options ? options.status : 200
this.status = options.status === undefined ? 200 : options.status
this.ok = this.status >= 200 && this.status < 300
this.statusText = 'statusText' in options ? options.statusText : 'OK'
this.headers = new Headers(options.headers)
Expand Down
7 changes: 7 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,13 @@ suite('Response', function() {
assert.isTrue(res.ok)
})

test('default status is 200 OK when an explicit undefined status code is passed', function() {
var res = new Response('', {status: undefined})
assert.equal(res.status, 200)
assert.equal(res.statusText, 'OK')
assert.isTrue(res.ok)
})

testBodyExtract(function(body) {
return new Response(body)
})
Expand Down

0 comments on commit 27473e9

Please sign in to comment.