| 19522 | return; |
| 19523 | } |
| 19524 | } |
| 19525 | const contentType = response.headersList.get("content-type", true); |
| 19526 | const mimeType = contentType !== null ? parseMIMEType(contentType) : "failure"; |
| 19527 | const contentTypeValid = mimeType !== "failure" && mimeType.essence === "text/event-stream"; |
| 19528 | if (response.status !== 200 || contentTypeValid === false) { |
| 19529 | this.close(); |
| 19530 | this.dispatchEvent(new Event("error")); |
| 19531 | return; |
| 19532 | } |
| 19533 | __privateSet(this, _readyState, OPEN); |
| 19534 | this.dispatchEvent(new Event("open")); |
| 19535 | __privateGet(this, _state).origin = response.urlList[response.urlList.length - 1].origin; |
| 19536 | const eventSourceStream = new EventSourceStream({ |
| 19537 | eventSourceSettings: __privateGet(this, _state), |
| 19538 | maxEventSize: (_a = __privateGet(this, _dispatcher).eventSourceOptions) == null ? void 0 : _a.maxEventSize, |
| 19539 | push: (event) => { |
| 19540 | this.dispatchEvent(createFastMessageEvent( |
| 19541 | event.type, |
| 19542 | event.options |
| 19543 | )); |
| 19544 | } |
| 19545 | }); |
| 19546 | pipeline( |
| 19547 | response.body.stream, |
| 19548 | eventSourceStream, |
| 19549 | (error) => { |
| 19550 | if ((error == null ? void 0 : error.aborted) === false) { |
| 19551 | this.close(); |
| 19552 | this.dispatchEvent(new Event("error")); |
| 19553 | } |