Skip to content

Commit

Permalink
Default Response status is 200 OK
Browse files Browse the repository at this point in the history
This is in accordance with Section 6.4 of the spec:

    dictionary ResponseInit {
      unsigned short status = 200;
      ByteString statusText = "OK";
      HeadersInit headers;
    };

Fixes JakeChampion#376
  • Loading branch information
mislav committed Nov 12, 2016
1 parent 4528229 commit 5fd8402
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@
}

this.type = 'default'
this.status = options.status
this.status = 'status' in options ? options.status : 200
this.ok = this.status >= 200 && this.status < 300
this.statusText = options.statusText
this.statusText = 'statusText' in options ? options.statusText : 'OK'
this.headers = new Headers(options.headers)
this.url = options.url || ''
this._initBody(bodyInit)
Expand Down
7 changes: 7 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ suite('Request', function() {

// https://fetch.spec.whatwg.org/#response-class
suite('Response', function() {
test('default status is 200 OK', function() {
var res = new Response()
assert.equal(res.status, 200)
assert.equal(res.statusText, 'OK')
assert.isTrue(res.ok)
})

// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
suite('BodyInit extract', function() {
featureDependent(suite, support.blob, 'type Blob', function() {
Expand Down

0 comments on commit 5fd8402

Please sign in to comment.