提交 5fd8402e 编写于 作者: M Mislav Marohnić

Default Response status is 200 OK

This is in accordance with Section 6.4 of the spec:

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

Fixes #376
上级 4528229e
...@@ -357,9 +357,9 @@ ...@@ -357,9 +357,9 @@
} }
this.type = 'default' this.type = 'default'
this.status = options.status this.status = 'status' in options ? options.status : 200
this.ok = this.status >= 200 && this.status < 300 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.headers = new Headers(options.headers)
this.url = options.url || '' this.url = options.url || ''
this._initBody(bodyInit) this._initBody(bodyInit)
......
...@@ -464,6 +464,13 @@ suite('Request', function() { ...@@ -464,6 +464,13 @@ suite('Request', function() {
// https://fetch.spec.whatwg.org/#response-class // https://fetch.spec.whatwg.org/#response-class
suite('Response', function() { 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 // https://fetch.spec.whatwg.org/#concept-bodyinit-extract
suite('BodyInit extract', function() { suite('BodyInit extract', function() {
featureDependent(suite, support.blob, 'type Blob', function() { featureDependent(suite, support.blob, 'type Blob', function() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册