Skip to content
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

[Web] Always return -1 as body length in HTTPClientWeb #79846

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

Faless
Copy link
Collaborator

@Faless Faless commented Jul 24, 2023

Body length cannot be reliably retrieved from the web. Reading the "content-length" value will return a meaningless value when the response is compressed, as reading will return uncompressed chunks in any case, resulting in a mismatch between the detected body size and the actual size returned by repeatedly calling read_response_body_chunk.

Additionally, while "content-length" is considered a safe CORS header, "content-encoding" is not, so using the "content-encoding" to decide if "content-length" is meaningful is not an option either.

We simply must accept the fact that browsers are awful when it comes to networking APIs.

See #47597 and #79327.

Reverts #77648.
Fixes #79327.

Body length cannot be reliably retrieved from the web.
Reading the "content-length" value will return a meaningless value when
the response is compressed, as reading will return uncompressed chunks
in any case, resulting in a mismatch between the detected body size and
the actual size returned by repeatedly calling read_response_body_chunk.

Additionally, while "content-length" is considered a safe CORS header,
"content-encoding" is not, so using the "content-encoding" to decide if
"content-length" is meaningful is not an option either.

We simply must accept the fact that browsers are awful when it comes to
networking APIs.
@Faless Faless added bug platform:web topic:network regression cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Jul 24, 2023
@Faless Faless added this to the 4.2 milestone Jul 24, 2023
@Faless Faless requested a review from a team as a code owner July 24, 2023 06:57
@YuriSizov YuriSizov changed the title [Web] Always return -1 as body length in HTTPClientWeb. [Web] Always return -1 as body length in HTTPClientWeb Jul 24, 2023
@YuriSizov YuriSizov merged commit bec47cd into godotengine:master Jul 24, 2023
@YuriSizov
Copy link
Contributor

Thanks!

@YuriSizov
Copy link
Contributor

Cherry-picked for 4.1.2.

@YuriSizov YuriSizov removed the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web export HTTPRequest returns RESULT_CANT_CONNECT when API uses compression
2 participants