| 12316 | } |
| 12317 | __name(makeAppropriateNetworkError, "makeAppropriateNetworkError"); |
| 12318 | function initializeResponse(response, init, body) { |
| 12319 | if (init.status !== null && (init.status < 200 || init.status > 599)) { |
| 12320 | throw new RangeError('init["status"] must be in the range of 200 to 599, inclusive.'); |
| 12321 | } |
| 12322 | if ("statusText" in init && init.statusText != null) { |
| 12323 | if (!isValidReasonPhrase(String(init.statusText))) { |
| 12324 | throw new TypeError("Invalid statusText"); |
| 12325 | } |
| 12326 | } |
| 12327 | if ("status" in init && init.status != null) { |
| 12328 | getResponseState(response).status = init.status; |
| 12329 | } |
| 12330 | if ("statusText" in init && init.statusText != null) { |
| 12331 | getResponseState(response).statusText = init.statusText; |
| 12332 | } |
| 12333 | if ("headers" in init && init.headers != null) { |
| 12334 | fill(getResponseHeaders(response), init.headers); |
| 12335 | } |
| 12336 | if (body) { |
| 12337 | if (nullBodyStatus.includes(response.status)) { |
| 12338 | throw webidl.errors.exception({ |
| 12339 | header: "Response constructor", |
| 12340 | message: `Invalid response status code ${response.status}` |
| 12341 | }); |
| 12342 | } |
| 12343 | getResponseState(response).body = body.body; |
| 12344 | if (body.type != null && !getResponseState(response).headersList.contains("content-type", true)) { |
| 12345 | getResponseState(response).headersList.append("content-type", body.type, true); |
| 12346 | } |
| 12347 | } |
| 12348 | } |
| 12349 | __name(initializeResponse, "initializeResponse"); |
| 12350 | function fromInnerResponse(innerResponse, guard) { |
| 12351 | const response = new Response(kConstruct); |