(body = null, init = undefined)
| 110 | |
| 111 | // https://fetch.spec.whatwg.org/#dom-response |
| 112 | constructor (body = null, init = undefined) { |
| 113 | webidl.util.markAsUncloneable(this) |
| 114 | |
| 115 | if (body === kConstruct) { |
| 116 | return |
| 117 | } |
| 118 | |
| 119 | if (body !== null) { |
| 120 | body = webidl.converters.BodyInit(body, 'Response', 'body') |
| 121 | } |
| 122 | |
| 123 | init = webidl.converters.ResponseInit(init) |
| 124 | |
| 125 | // 1. Set this’s response to a new response. |
| 126 | this.#state = makeResponse({}) |
| 127 | |
| 128 | // 2. Set this’s headers to a new Headers object with this’s relevant |
| 129 | // Realm, whose header list is this’s response’s header list and guard |
| 130 | // is "response". |
| 131 | this.#headers = new Headers(kConstruct) |
| 132 | setHeadersGuard(this.#headers, 'response') |
| 133 | setHeadersList(this.#headers, this.#state.headersList) |
| 134 | |
| 135 | // 3. Let bodyWithType be null. |
| 136 | let bodyWithType = null |
| 137 | |
| 138 | // 4. If body is non-null, then set bodyWithType to the result of extracting body. |
| 139 | if (body != null) { |
| 140 | const [extractedBody, type] = extractBody(body) |
| 141 | bodyWithType = { body: extractedBody, type } |
| 142 | } |
| 143 | |
| 144 | // 5. Perform initialize a response given this, init, and bodyWithType. |
| 145 | initializeResponse(this, init, bodyWithType) |
| 146 | } |
| 147 | |
| 148 | // Returns response’s type, e.g., "cors". |
| 149 | get type () { |
nothing calls this directly
no test coverage detected