484 Commits
Author SHA1 Message Date
Ferdinand Malcher 6838c9bc77 docs(http): fix typo in httpResource params description 2026-11-20 08:35:52 -08:00
Matthieu Riegler effbe56432 feat(http): add HttpClient.query() method for HTTP QUERY requests
This commit adds the `HttpClient.query()` method to `HttpClient` in order to support HTTP QUERY method as defined in RFC 10008.

fixes #70856
2026-11-11 14:59:29 -08:00
nagahara-naoki 818742755c fix(http): clean up pending tasks when interceptors throw synchronously
Remove the registered pending task when an interceptor chain throws before
returning an Observable. Preserve the original error for the caller and keep
finalize responsible for completion, Observable errors, and cancellation.

Apply cleanup to both the outer HTTP handler and the legacy interceptor
adapter, since each registers its own task that can otherwise block stability.

Add tests for synchronous errors, Observable errors, completion, and
unsubscribe with both functional and legacy interceptors.

Closes #71953
2026-11-11 13:17:27 -08:00
nagahara-naoki 00ea9a4556 fix(common): omit empty arrays from HttpParams
Skip empty arrays in fromObject so parameter accessors agree with the
serialized query and get does not return undefined.

Fixes #71916
2026-11-10 16:17:51 -08:00
Alex Rickabaugh 00e584e698 fix(http): mark httpResource top-level IIFE as pure
`httpResource` is initialized via a top-level IIFE so that sub-constructors
(`arrayBuffer`, `blob`, `text`) can be attached to the function object.
Without a `/* @__PURE__ */` annotation, Closure Compiler and other bundlers
treat this top-level IIFE as potentially side-effectful, retaining `httpResource`
and its transitive dependencies even when unused.
2026-11-09 16:56:35 -08:00
SkyZeroZx b7cf38695f perf(http): tree-shake unused transfer cache from httpResource
Provide cache lookup through the existing private transfer-cache options so httpResource clients without transfer caching do not retain cache restoration and hashing.

Preserve the optional dependency lookups, their timing, and synchronous hydration behavior. Update the http bundle golden to show the removal of the cache-related symbols.
2026-11-09 16:51:36 -08:00
Matthieu Riegler 9bbb7c9d46 build(docs-infra): move framework API doc generation targets under //adev
Previously, `generate_api_docs(...)` targets lived directly in each
`//packages/**/BUILD.bazel` file (and `render_api_to_html(...)` in
`//tools/manual_api_docs/{blocks,elements}/BUILD.bazel`). Because
`render_api_to_html` validates links against
`//adev/scripts/routes:defined-routes.json`, running wildcard package
builds or tests such as `bazel test //packages/forms/...` pulled in the
`//adev/...` route generation and API manifest dependency graph across
all packages.

Move all framework `generate_api_docs` and manual API `render_api_to_html`
targets into `//adev/src/content/api` alongside `aria`, `cdk`, and `cli`,
leaving only lightweight `files_for_docgen` filegroups in `//packages/...`
and JSON extraction targets in `//tools/manual_api_docs/...`. Remove the
`generate_api_docs` wrapper from `//tools:defaults.bzl` so neither
`//packages/...` nor `//tools/...` loads or depends on `//adev/...`, and
add `//adev/src/content/api:api_docs_test` so `bazel test //adev/...`
explicitly exercises API doc generation and link validation.
2026-10-26 11:38:58 -07:00
SkyZeroZx d39f913dfb test(http): add XSRF specs for backslash and whitespace URLs
Browsers resolve these URLs to another origin, so the interceptor must
not attach the XSRF token to them.
2026-10-22 13:28:14 -07:00
Kristiyan Kostadinov bc22890f53 fix(http): account for multiple cache control headers
Updates the logic that detects the `Cache-Control` header to account for multiple values. This is a bit of an edge case, but could technically happen.
2026-10-20 00:42:56 -07:00
Matthieu Riegler 3715109a2a docs: update the initializer fn entries.
https://angular.dev/api?type=initializer_api_function&status=15 should only show the function that have special meaning for the compiler
2026-10-19 18:34:45 -07:00
Kristiyan Kostadinov 01c883e2b6 fix(common): harden param encoding against prototype pollution
The parameter encoding was using a plain object literal lookup to determine how to encode specific characters. This makes it vulnerable to prototype pollution.

These changes mitigate the issue by storing the mapping in a native `Map` instead.
2026-10-14 11:37:56 +02:00
Matthieu Riegler ecbc89b465 refactor(core): modernize unit tests across all packages
This should also help preventing agent from generating code that doesn't follow our latest guidelines.
2026-10-12 15:26:29 -07:00
Amine f458730d37 fix(http): forward reportProgress of httpResource as reportDownloadProgress
`HttpClient` split `reportProgress` into `reportUploadProgress` and
`reportDownloadProgress`, but `httpResource` still passed its
`reportProgress` option to the deprecated `reportProgress` of
`HttpRequest`.

The `progress` signal of `httpResource` only tracks download events, so
`reportProgress` there already means download progress. Forward it as
`reportDownloadProgress` instead of adding a new option.
2026-09-29 13:56:08 -07:00
arturovt 5128dec0ca fix(common): remove abort listener on the abort path too in httpResource
httpResource registers an 'abort' listener on the resource's AbortSignal
to unsubscribe the underlying request when it's cancelled. The listener
was only removed from the subscription's own error/complete callbacks,
but calling sub.unsubscribe() directly - which is exactly what happens
when the listener itself fires - doesn't trigger those callbacks. So on
the one path where the signal actually aborts, the listener was never
removed.

Passing { once: true } lets the removal happen automatically once the
listener fires, covering that path without touching the existing
error/complete cleanup, which is still needed for the paths where the
request finishes without ever aborting.

This also happens to route around a real leak on affected engines: an
AbortSignal that's had any listener attached isn't garbage collected
until it fires. https://bugs.webkit.org/show_bug.cgi?id=298499
2026-09-21 11:57:15 -07:00
Shuaib Hasan Akib 1bc7e3c2c3 refactor(core): use native Promise.withResolvers() in remaining tests
Replaces the remaining hand-rolled deferred promise implementations
with the native `Promise.withResolvers()` API and removes the now
unused helper and import.

Follow-up to #69739.
2026-09-09 16:17:04 +02:00
Kristiyan Kostadinov 732e505018 fix(core): replace all hasOwnProperty usages with Object.hasOwn
We keep getting PRs that target single usages of `hasOwnProperty` and we have ~100 of them. These changes aim to address the issue centrally by swapping out all the instances and adding a lint rule against introducing new ones.
2026-08-18 09:17:18 -07:00
SkyZeroZx 1a006a8f97 fix(http): cancel oversized fetch response bodies
Cancel the unread response body before reporting NG02825 when its declared Content-Length exceeds the configured buffer limit. Without cancellation, SSR can finish while the underlying connection remains open.

Add regression coverage for the declared-length rejection path.
2026-08-17 13:52:12 -07:00
SkyZeroZx 09bc90003e fix(http): always decode JSON responses as UTF-8
Keep the charset handling added in #70062 limited to text responses. JSON
bytes must stay UTF-8 regardless of the Content-Type charset.

Fetch defines Body.json() using "parse JSON from bytes". Infra specifies that
step as: "Let string be the result of running UTF-8 decode on bytes."

https://fetch.spec.whatwg.org/#dom-body-json
https://infra.spec.whatwg.org/#parse-json-bytes-to-a-javascript-value
2026-08-07 15:54:20 -07:00
Matthieu Riegler ef4dfead83 fix(http): avoid aborting completed requests in FetchBackend
Prevent AbortController.abort() from executing during Observable teardown when a FetchBackend HTTP request has already completed successfully or errored.
Previously, FetchBackend unconditionally called abort() upon stream termination. When requests completed normally, calling abort() after delivery caused Chromium-based browsers to mark the resolved request as net::ERR_ABORTED in DevTools due to a race condition, leading to missing response body payloads ("Failed to load response data"). By tracking whether the request has already settled—similar to XhrBackend checking for xhr.readyState !== xhr.DONE—we ensure abort() is only called for unsettled, in-flight requests upon unsubscription.

Fixes #70071
2026-08-04 09:37:35 -07:00
Alan Agius 280d09b160 fix(http): strip RFC 6265 DQUOTE characters and handle URIError in parseCookieValue
Previously, `parseCookieValue` did not strip enclosing double quotes (`DQUOTE`) from quoted cookie values as specified in RFC 6265 Section 4.1.1. In addition, malformed percent-encoding in cookie values caused an unhandled `URIError` when calling `decodeURIComponent`.
2026-08-04 08:29:46 -07:00
Matthieu Riegler 6a0789dc7f fix(http): respect content-type charset in fetch backend text decoder
Extract the charset parameter from the Content-Type response header in FetchBackend and pass it to TextDecoder when decoding text and json responses. When no valid charset is provided or supported, gracefully fall back to default utf-8 decoding.

Fixes #70061
2026-08-04 08:28:23 -07:00
Jaime Burgos bb78286e5e fix(http): run root interceptors in the terminal request chain
Represent withRequestsMadeViaParent() with an internal delegating backend so the interceptor handler can distinguish delegated clients from independent child configurations.
2026-07-31 08:32:14 -07:00
Shuaib Hasan Akib ec87f04200 refactor(common): replaces the deprecated positional subscribe arguments with the
recommended observer object
2026-07-29 09:43:52 -07:00
Jaime Burgos de240a5d0e fix(http): enable xsrf for root-provided HttpClient
Include the XSRF interceptor in the root token factory so the automatically provided HttpClient retains the documented default protection without requiring provideHttpClient().
2026-07-29 08:40:09 -07:00
SkyZeroZx f33ee95045 fix(http): match header values exactly when deleting
Normalize value-specific HttpHeaders deletions before filtering. The string overload previously used String#indexOf and removed shorter values contained within the requested deletion value, potentially widening outgoing request metadata.

Preserve delete-all behavior only when no value is supplied, and cover string, array, and empty-string deletion.
2026-07-29 08:39:07 -07:00
SkyZeroZx ff02a16749 fix(http): preserve immutability of materialized clones
Prevent lazy HttpHeaders and HttpParams clones from reusing value arrays owned by a materialized source. Append and value-specific delete operations previously mutated those shared arrays, violating the immutable API contract and allowing request metadata to bleed into later requests.

Share value arrays until an update mutates a specific header or parameter, then copy only that array. Cover the affected append and delete paths with regression tests that materialize the source first.
2026-07-29 08:39:07 -07:00
arshiya tabasum 3192dccaa3 fix(http): prevent transfer cache key collisions
`makeCacheKey` joined the request fields with `|` before hashing. The url
and the serialized body can contain `|` themselves, so a shifted field
boundary (url `/items/a` + body `b|c` vs url `/items/a|b` + body `c`)
produced the same joined string and the same key, letting two distinct
requests share a transfer cache slot.

Join with `\0` instead, which cannot occur in a valid url or in encoded
params, so the field boundaries cannot be forged by field content.
2026-07-20 14:39:51 +02:00
Sonu Kapoor 6d043f8657 fix(http): prevent interceptor signal reads from leaking into calling reactive contexts
When `HttpClient` is called from within an `effect()` or other reactive
context, any signal reads performed inside HTTP interceptors were
inadvertently tracked by that context. This caused the effect to
re-execute whenever those signals changed, regardless of whether the
signal was semantically related to the HTTP call.

The fix wraps the interceptor chain invocation in `untracked()` so that
signal reads inside interceptors — both functional (`withInterceptors`)
and class-based (`withInterceptorsFromDi`) — are invisible to the
calling reactive context. This matches the precedent set by the resource
API, which also wraps its loader in `untracked()` for the same reason.

Fixes #58682
2026-07-14 09:21:07 -07:00
Alan Agius e3630c23c5 feat(http): add options to allow caching of credentialed and non-cacheable HTTP requests
Adds `includeRequestsWithCredentials` and `includeNonCacheableRequests` options to `HttpTransferCacheOptions`.
2026-07-06 14:03:32 -07:00
SkyZeroZx 7ea2a002f5 docs: add documentation for HttpClient response body size limit and related error NG02825 2026-06-29 14:27:26 -07:00