diff --git a/fetch.js b/fetch.js index 15cc1c611ddaa559092437bab2ff8cae056f1cd4..68db677d34c10874e789adce16c7b990bce82565 100644 --- a/fetch.js +++ b/fetch.js @@ -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) diff --git a/test/test.js b/test/test.js index cd4c433fe6bad7ecba4e3146f83f71391e12485f..2aa727e081d12735f3c704d6a4adc23fe31fb962 100644 --- a/test/test.js +++ b/test/test.js @@ -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() {