MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

deps/undici/undici.js:12060–12079  ·  view source on GitHub ↗
(body = null, init = void 0)

Source from the content-addressed store, hash-verified

12058 }
12059 // https://fetch.spec.whatwg.org/#dom-response
12060 constructor(body = null, init = void 0) {
12061 webidl.util.markAsUncloneable(this);
12062 if (body === kConstruct) {
12063 return;
12064 }
12065 if (body !== null) {
12066 body = webidl.converters.BodyInit(body, "Response", "body");
12067 }
12068 init = webidl.converters.ResponseInit(init);
12069 this.#state = makeResponse({});
12070 this.#headers = new Headers(kConstruct);
12071 setHeadersGuard(this.#headers, "response");
12072 setHeadersList(this.#headers, this.#state.headersList);
12073 let bodyWithType = null;
12074 if (body != null) {
12075 const [extractedBody, type] = extractBody(body);
12076 bodyWithType = { body: extractedBody, type };
12077 }
12078 initializeResponse(this, init, bodyWithType);
12079 }
12080 // Returns response?s type, e.g., "cors".
12081 get type() {
12082 webidl.brandCheck(this, _Response);

Callers

nothing calls this directly

Calls 4

markAsUncloneableMethod · 0.80
makeResponseFunction · 0.70
extractBodyFunction · 0.70
initializeResponseFunction · 0.70

Tested by

no test coverage detected