MCPcopy Create free account
hub / github.com/angular/dev-infra / reply

Method reply

github-actions/browserstack/set-browserstack-env.js:11274–11297  ·  view source on GitHub ↗

* Mock an undici request with a defined reply.

(replyOptionsCallbackOrStatusCode)

Source from the content-addressed store, hash-verified

11272 } else {
11273 handleReply(this[kDispatches]);
11274 }
11275 function handleReply(mockDispatches, _data = data) {
11276 var _a, _b, _c, _d;
11277 const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers;
11278 const body = typeof _data === "function" ? _data(__spreadProps(__spreadValues({}, opts), { headers: optsHeaders })) : _data;
11279 if (isPromise(body)) {
11280 body.then((newData) => handleReply(mockDispatches, newData));
11281 return;
11282 }
11283 const responseData = getResponseData(body);
11284 const responseHeaders = generateKeyValues(headers);
11285 const responseTrailers = generateKeyValues(trailers);
11286 (_a = handler.onConnect) == null ? void 0 : _a.call(handler, (err) => handler.onError(err), null);
11287 (_b = handler.onHeaders) == null ? void 0 : _b.call(handler, statusCode, responseHeaders, resume, getStatusText(statusCode));
11288 (_c = handler.onData) == null ? void 0 : _c.call(handler, Buffer.from(responseData));
11289 (_d = handler.onComplete) == null ? void 0 : _d.call(handler, responseTrailers);
11290 deleteMockDispatch(mockDispatches, key);
11291 }
11292 function resume() {
11293 }
11294 return true;
11295 }
11296 function buildMockDispatch() {
11297 const agent = this[kMockAgent];
11298 const origin = this[kOrigin];
11299 const originalDispatch = this[kOriginalDispatch];
11300 return function dispatch(opts, handler) {

Callers

nothing calls this directly

Calls 3

addMockDispatchFunction · 0.70

Tested by

no test coverage detected