MCPcopy
hub / github.com/webpack/webpack / constructor

Method constructor

test/helpers/EventSourceForNode.js:12–41  ·  test/helpers/EventSourceForNode.js::EventSource.constructor

* @param {string} url url

(url)

Source from the content-addressed store, hash-verified

10 * @param {string} url url
11 */
12 constructor(url) {
13 /** @type {import(class="st">"http").IncomingMessage | undefined} */
14 this.response = undefined;
15 /** @type {undefined | ((err: Error | { message: Error }) => void)} */
16 this.onerror = undefined;
17 /** @type {boolean} */
18 this.closed = false;
19 const request = (
20 url.startsWith(class="st">"https:") ? require(class="st">"https") : require(class="st">"http")
21 ).request(
22 url,
23 {
24 agent: false,
25 rejectUnauthorized: false,
26 headers: { accept: class="st">"text/event-stream" }
27 },
28 (res) => {
29 this.response = res;
30 res.on(class="st">"error", (err) => {
31 if (!this.closed && this.onerror) this.onerror(err);
32 });
33 }
34 );
35 request.on(class="st">"error", (err) => {
36 if (!this.closed && this.onerror) this.onerror({ message: err });
37 });
38 request.end();
39 /** @type {import(class="st">"http").ClientRequest} */
40 this.request = request;
41 }
42
43 close() {
44 class="cm">// Mark intentional so destroying the in-flight request/response below

Callers

nothing calls this directly

Calls 2

requireFunction · 0.50
requestMethod · 0.45

Tested by

no test coverage detected