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

fix: set correct "Content-Length" response header for special characters (#2045) #2046

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

ZeroCho
Copy link
Contributor

@ZeroCho ZeroCho commented Feb 20, 2024

@kettanaito
fyi, '안녕 세상', which has 13 bytes (4 Korean characters * 3b + 1b(space) === 13b), means 'hello world' in Korean.
{ firstName: '제로' } turns into {"firstName":"제로"} which has 22 bytes (16 ASCII characters + 2 Korean characters * 3b === 22b)

@technikhil314
Copy link

@kettanaito Can we have this merged? We too have some api that returns currency symbols which are special characters and the response is getting truncated because of this.

@ZeroCho
Copy link
Contributor Author

ZeroCho commented Feb 27, 2024

@technikhil314 Until this PR gets merged, you have to manually set correct 'Content-Length' header for every response with special characters, for your response not to be truncated.

@Jesse1989pp
Copy link

Jesse1989pp commented Feb 27, 2024

@technikhil314 Until this PR gets merged, you have to manually set correct 'Content-Length' header for every response with special characters, for your response not to be truncated.

That drastically gave performance issues for us with a json response. We have a workaround with a text response including Content-Type': 'application/json; charset=utf8’ as a header.. 😅

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

This is great! Thank you for fixing this, @ZeroCho. 🚀

@kettanaito kettanaito changed the title fix: 'Content-Length' header in response with special characters (#2045) fix: set correct 'Content-Length' response header for special characters (#2045) Feb 27, 2024
@kettanaito kettanaito changed the title fix: set correct 'Content-Length' response header for special characters (#2045) fix: set correct "Content-Length" response header for special characters (#2045) Feb 27, 2024
@kettanaito kettanaito merged commit eb3e284 into mswjs:main Feb 27, 2024
10 checks passed
@kettanaito
Copy link
Member

Released: v2.2.2 🎉

This has been released in v2.2.2!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

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.

JSON response with special chars truncated since 2.2.0
4 participants