Skip to content

Remove content-length when using web clients#20

Merged
srikrsna-buf merged 1 commit into
connectrpc:mainfrom
benridley:main
May 9, 2025
Merged

Remove content-length when using web clients#20
srikrsna-buf merged 1 commit into
connectrpc:mainfrom
benridley:main

Conversation

@benridley

Copy link
Copy Markdown
Contributor

This PR ensures we always remove the content-length & content-encoding headers when using fetch-based HTTP clients.

It was discovered that when performing length checks in the protocol code, the length supplied by these clients was often incorrect because the browser has already performed decompression on the response. By removing these headers when using the web client, we forgo length checks and instead rely on the protocol parsing to validate any malformed responses.

Fixes #13.

@srikrsna-buf srikrsna-buf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can you also signoff on the commits?

Comment thread packages/connect/lib/src/web.dart Outdated
Comment thread packages/connect/lib/src/web.dart Outdated
@nicksnyder nicksnyder changed the title Always remove content-length when using web clients Remove content-length when using web clients May 8, 2025
Signed-off-by: Ben Ridley <ben@brids.dev>
@benridley

Copy link
Copy Markdown
Contributor Author

Oops sorry for the noise @srikrsna-buf, I think it must have been auto formatting.

Anyway, I've signed off and removed the unrelated edits. Thanks!

@srikrsna-buf srikrsna-buf merged commit 05aa3fe into connectrpc:main May 9, 2025
15 checks passed
@srikrsna-buf srikrsna-buf mentioned this pull request May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Protocol error (promised bytes vs received bytes) when using web / fetch client

2 participants