Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix onprogress not firing when Content-Length is not available for XM…
…LHttpRequest (#44899) Summary: When an XMLHttpRequest is performed, the `onprogress` event it is not invoked when the `Content-Length` header is missing in the response. This is the case when we are calling an endpoint that responds with `transfer-encoding: chunked` (https://tools.ietf.org/html/rfc9112#section-7.1), preventing the user to keep track of the progress while the server is sending chunks. Despite we will never know the total length of the content (because it will not be known due to the RFC specification, so it will be always `-1`), we will now be able to keep track of the loaded data. Note that in Android, this is the current default behaviour. To address this issue: - I removed the condition where the `downloadProgressBlock` was dispatched only when `response.expectedContentLength` was greater than 0 - I created a new test case for `XMLHttpRequest` in the tester app to download a chunked file ## Changelog: [IOS] [CHANGED] - fire `onprogress` event for `XMLHttpRequest` even when the `Content-Length` header is missing in the response headers Pull Request resolved: #44899 Test Plan: |before|after| |----------|:-------------:| |https://github.com/facebook/react-native/assets/37150312/6da3518f-eed3-4808-a2f8-abe26e5c7487|https://github.com/facebook/react-native/assets/37150312/ed1da300-dcf7-4874-a941-a2289f1cb777 Reviewed By: cortinico Differential Revision: D58562088 Pulled By: NickGerleman fbshipit-source-id: 23a1cafa49ddcd25fa0db7d04fae845126771425
- Loading branch information