Repository navigation
feat(http): Use the Fetch backend by default - #58212
Conversation
2a9e50c to
84b663b
Compare
84b663b to
b86dc15
Compare
There was a problem hiding this comment.
I think it would be meaningful to extend this a bit with information on what this offers, especially its support for upload progress events.
Thinking about it more, do we already document this limitation of fetch for the 'progress' response mode? We should probably make it clear there as well that withXhr is needed to make it work. Does the fetch backend report an error somehow if progress is requested? Is this actually only about upload progress, or also download progress?
There was a problem hiding this comment.
Chrome is the only browser that supports a stream as a body (since M105), every browser support streaming the response (hence the support for download progress report).
The FetchBackend doesn't throw any error, it won't just report any progress on uploads. Currently the API only has a single reportProgress property for both update & download progress report, I don't think we should log any warning.
I've updated the doc for the reportProgress property to hint a the new limitation with the default implementation.
There was a problem hiding this comment.
For this use case, it's unfortunate that reportProgress is used for both upload and download, which is why I understand that you don't want a warning. However, given it doesn't seem to be possible to use duplex: "half" with Angular's fetch-backend yet (correct me if I'm wrong), I think a warning would still be good if you set reportProgress to true in dev mode, regardless - at least for now.
Not sure what the ratio is of devs using it to report uploads vs. downloads, but from my anecdotal experience, it's usually for uploads.
ed0d097 to
41065de
Compare
b17f586 to
25b88b5
Compare
a32e2e8 to
e95bdc1
Compare
e95bdc1 to
aa7320f
Compare
|
Migration ✅ |
| * Note: The default `HttpBackend` based on fetch, does not support progress report for uploads. | ||
| * Set the `HttpXhrBackend` with `withXhr()` if you need this feature. | ||
| */ | ||
| readonly reportProgress: boolean = false; |
There was a problem hiding this comment.
As a follow-up, we'll probably deprecate that property and split it into reportUploadProgress and reportDownloadProgress with only the former logging an error when the fetchBackend is used.
253e078 to
e8e1aaf
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
e8e1aaf to
52e9740
Compare
|
TGP surfaced some testing failures (where tests use a custom XhrFactory to mock requests). Cleanup in progress. |
…mentation This commit replaces the `XhrHttpBackend` with the `FetchBackend` as the default implementation of the `HttpBackend`. This introduces a breaking change a the `FetchBackend` does not support the report progress for uploads. The previous behavior (`HttpXhrBackend`) can be restored by setting `withXhr()` in the `provideHttpClient()` provider function. DEPRECATED: `withFetch` is now deprecated, it can be safely removed. BREAKING CHANGE: Use the `HttpXhrBackend` with `provideHttpClient(withXhr)` if you want to keep supporting upload progress reports.
…sing the `HttpXhrBackend` implementation. Exisiting applications will be migrated to keep using the XHR backend to prevent any breaking changes. `withXhr()` is to the `provideHttpClient` provider function.
52e9740 to
4f6190e
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit replaces the
HttpXhrBackendwith theFetchBackendas the default implementation of theHttpBackend.This introduces a breaking change a the
FetchBackenddoes not support the report progress for uploads.The previous behavior (
HttpXhrBackend) can be enabled by settingwithXhr()in theprovideHttpClient()provider function.This PR includes a migration schematics to keep the behavior of existing apps as is.
DEPRECATION:
withFetchis now deprecated, it can be safely removed.BREAKING CHANGE: Use the
HttpXhrBackendwithprovideHttpClient(withXhr())if you want to keep supporting upload progress reports.