MCPcopy
hub / github.com/angular/angular / newRequestWithMetadata

Function newRequestWithMetadata

packages/service-worker/worker/src/assets.ts:520–549  ·  view source on GitHub ↗

* Create a new `Request` based on the specified URL and `RequestInit` options, preserving only * metadata that are known to be safe. * * Currently, headers, referrer, referrer policy, redirect policy, an explicit * `credentials: 'omit'`, and the HTTP cache mode are preserved. On cross-or

(url: string, options: Request)

Source from the content-addressed store, hash-verified

518 * https://github.com/angular/angular/issues/41931#issuecomment-1227601347.
519 */
520 private newRequestWithMetadata(url: string, options: Request): Request {
521 let headers = options.headers;
522 const parsedUrl = this.adapter.parseUrl(url, this.adapter.origin);
523
524 const hasHeaders = headers.keys().next().done !== true;
525
526 if (hasHeaders && parsedUrl.origin !== this.adapter.origin) {
527 headers = this.adapter.newHeaders(options.headers);
528 headers.delete('Authorization');
529 headers.delete('Proxy-Authorization');
530 headers.delete('Cookie');
531 }
532
533 const init: RequestInit = {
534 headers,
535 referrer: options.referrer,
536 referrerPolicy: options.referrerPolicy,
537 redirect: options.redirect,
538 };
539
540 if (options.credentials === 'omit') {
541 init.credentials = 'omit';
542 }
543
544 if (options.cache !== undefined) {
545 init.cache = options.cache;
546 }
547
548 return this.adapter.newRequest(url, init);
549 }
550
551 /**
552 * Construct a cache-busting URL for a given URL.

Callers

nothing calls this directly

Calls 6

keysMethod · 0.65
parseUrlMethod · 0.45
nextMethod · 0.45
newHeadersMethod · 0.45
deleteMethod · 0.45
newRequestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…