@angular/common 21.0.0-next.0 → 21.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.0.0-next.0
2
+ * @license Angular v21.0.0-next.2
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -690,12 +690,6 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
690
690
  * (or content types) the client is willing to receive from the server.
691
691
  */
692
692
  const ACCEPT_HEADER = 'Accept';
693
- /**
694
- * `X-Request-URL` is a custom HTTP header used in older browser versions,
695
- * including Firefox (< 32), Chrome (< 37), Safari (< 8), and Internet Explorer,
696
- * to include the full URL of the request in cross-origin requests.
697
- */
698
- const X_REQUEST_URL_HEADER = 'X-Request-URL';
699
693
  /**
700
694
  * `text/plain` is a content type used to indicate that the content being
701
695
  * sent is plain text with no special formatting or structured data
@@ -1137,6 +1131,20 @@ class HttpResponseBase {
1137
1131
  * When using the default XHR Request this property will be `undefined`
1138
1132
  */
1139
1133
  redirected;
1134
+ /**
1135
+ * Indicates the type of the HTTP response, based on how the request was made and how the browser handles the response.
1136
+ *
1137
+ * This corresponds to the `type` property of the Fetch API's `Response` object, which can indicate values such as:
1138
+ * - `'basic'`: A same-origin response, allowing full access to the body and headers.
1139
+ * - `'cors'`: A cross-origin response with CORS enabled, exposing only safe response headers.
1140
+ * - `'opaque'`: A cross-origin response made with `no-cors`, where the response body and headers are inaccessible.
1141
+ * - `'opaqueredirect'`: A response resulting from a redirect followed in `no-cors` mode.
1142
+ * - `'error'`: A response representing a network error or similar failure.
1143
+ *
1144
+ * This property is only available when using the Fetch-based backend (via `withFetch()`).
1145
+ * When using Angular's (XHR) backend, this value will be `undefined`.
1146
+ */
1147
+ responseType;
1140
1148
  /**
1141
1149
  * Super-constructor for all responses.
1142
1150
  *
@@ -1151,6 +1159,7 @@ class HttpResponseBase {
1151
1159
  this.statusText = init.statusText || defaultStatusText;
1152
1160
  this.url = init.url || null;
1153
1161
  this.redirected = init.redirected;
1162
+ this.responseType = init.responseType;
1154
1163
  // Cache the ok value to avoid defining a getter.
1155
1164
  this.ok = this.status >= 200 && this.status < 300;
1156
1165
  }
@@ -1217,6 +1226,7 @@ class HttpResponse extends HttpResponseBase {
1217
1226
  statusText: update.statusText || this.statusText,
1218
1227
  url: update.url || this.url || undefined,
1219
1228
  redirected: update.redirected ?? this.redirected,
1229
+ responseType: update.responseType ?? this.responseType,
1220
1230
  });
1221
1231
  }
1222
1232
  }
@@ -1335,18 +1345,6 @@ var HttpStatusCode;
1335
1345
  })(HttpStatusCode || (HttpStatusCode = {}));
1336
1346
 
1337
1347
  const XSSI_PREFIX$1 = /^\)\]\}',?\n/;
1338
- /**
1339
- * Determine an appropriate URL for the response, by checking either
1340
- * response url or the X-Request-URL header.
1341
- */
1342
- function getResponseUrl$1(response) {
1343
- if (response.url) {
1344
- return response.url;
1345
- }
1346
- // stored as lowercase in the map
1347
- const xRequestUrl = X_REQUEST_URL_HEADER.toLocaleLowerCase();
1348
- return response.headers.get(xRequestUrl);
1349
- }
1350
1348
  /**
1351
1349
  * An internal injection token to reference `FetchBackend` implementation
1352
1350
  * in a tree-shakable way.
@@ -1426,7 +1424,7 @@ class FetchBackend {
1426
1424
  }
1427
1425
  const headers = new HttpHeaders(response.headers);
1428
1426
  const statusText = response.statusText;
1429
- const url = getResponseUrl$1(response) ?? request.urlWithParams;
1427
+ const url = response.url || request.urlWithParams;
1430
1428
  let status = response.status;
1431
1429
  let body = null;
1432
1430
  if (request.reportProgress) {
@@ -1505,7 +1503,7 @@ class FetchBackend {
1505
1503
  headers: new HttpHeaders(response.headers),
1506
1504
  status: response.status,
1507
1505
  statusText: response.statusText,
1508
- url: getResponseUrl$1(response) ?? request.urlWithParams,
1506
+ url: response.url || request.urlWithParams,
1509
1507
  }));
1510
1508
  return;
1511
1509
  }
@@ -1520,6 +1518,7 @@ class FetchBackend {
1520
1518
  // asked for JSON data and the body cannot be parsed as such.
1521
1519
  const ok = status >= 200 && status < 300;
1522
1520
  const redirected = response.redirected;
1521
+ const responseType = response.type;
1523
1522
  if (ok) {
1524
1523
  observer.next(new HttpResponse({
1525
1524
  body,
@@ -1528,6 +1527,7 @@ class FetchBackend {
1528
1527
  statusText,
1529
1528
  url,
1530
1529
  redirected,
1530
+ responseType,
1531
1531
  }));
1532
1532
  // The full body has been received and delivered, no further events
1533
1533
  // are possible. This request is complete.
@@ -1541,6 +1541,7 @@ class FetchBackend {
1541
1541
  statusText,
1542
1542
  url,
1543
1543
  redirected,
1544
+ responseType,
1544
1545
  }));
1545
1546
  }
1546
1547
  }
@@ -1651,20 +1652,6 @@ function silenceSuperfluousUnhandledPromiseRejection(promise) {
1651
1652
  }
1652
1653
 
1653
1654
  const XSSI_PREFIX = /^\)\]\}',?\n/;
1654
- const X_REQUEST_URL_REGEXP = RegExp(`^${X_REQUEST_URL_HEADER}:`, 'm');
1655
- /**
1656
- * Determine an appropriate URL for the response, by checking either
1657
- * XMLHttpRequest.responseURL or the X-Request-URL header.
1658
- */
1659
- function getResponseUrl(xhr) {
1660
- if ('responseURL' in xhr && xhr.responseURL) {
1661
- return xhr.responseURL;
1662
- }
1663
- if (X_REQUEST_URL_REGEXP.test(xhr.getAllResponseHeaders())) {
1664
- return xhr.getResponseHeader(X_REQUEST_URL_HEADER);
1665
- }
1666
- return null;
1667
- }
1668
1655
  /**
1669
1656
  * Validates whether the request is compatible with the XHR backend.
1670
1657
  * Show a warning if the request contains options that are not supported by XHR.
@@ -1807,7 +1794,7 @@ class HttpXhrBackend {
1807
1794
  const headers = new HttpHeaders(xhr.getAllResponseHeaders());
1808
1795
  // Read the response URL from the XMLHttpResponse instance and fall back on the
1809
1796
  // request URL.
1810
- const url = getResponseUrl(xhr) || req.url;
1797
+ const url = xhr.responseURL || req.url;
1811
1798
  // Construct the HttpHeaderResponse and memoize it.
1812
1799
  headerResponse = new HttpHeaderResponse({ headers, status: xhr.status, statusText, url });
1813
1800
  return headerResponse;