-
Notifications
You must be signed in to change notification settings - Fork 24.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix onprogress not firing when Content-Length is not available for XMLHttpRequest #44899
Fix onprogress not firing when Content-Length is not available for XMLHttpRequest #44899
Conversation
Hi @BadLice! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
8084223
to
5507b8b
Compare
Base commit: b8f1b92 |
@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@NickGerleman merged this pull request in 457d14b. |
This pull request was successfully merged by alicata in 457d14b. When will my fix make it into a release? | How to file a pick request? |
Summary:
When an XMLHttpRequest is performed, the
onprogress
event it is not invoked when theContent-Length
header is missing in the response. This is the case when we are calling an endpoint that responds withtransfer-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:
downloadProgressBlock
was dispatched only whenresponse.expectedContentLength
was greater than 0XMLHttpRequest
in the tester app to download a chunked fileChangelog:
[IOS] [CHANGED] - fire
onprogress
event forXMLHttpRequest
even when theContent-Length
header is missing in the response headersTest Plan: