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

Content-Length invalid for unicode text #332

Open
to-miz opened this issue Nov 3, 2023 · 1 comment
Open

Content-Length invalid for unicode text #332

to-miz opened this issue Nov 3, 2023 · 1 comment

Comments

@to-miz
Copy link

to-miz commented Nov 3, 2023

When generating a http request string, the content-length seems to be calculated using the number of codepoints instead of bytes.
This was generated using insomnia, which uses httpsnippet:

POST /api/v1/test HTTP/1.1
Content-Type: text/plain
User-Agent: insomnia/2023.5.8
Host: localhost:5003
Content-Length: 3

äöü

This is what insomnia actually sends when executing the request (visualized using nc -l localhost 5003)

$ nc -l localhost 5003
POST /api/v1/test HTTP/1.1
Host: localhost:5003
Content-Type: text/plain
User-Agent: insomnia/2023.5.8
Accept: */*
Content-Length: 6

äöü
@erunion
Copy link
Contributor

erunion commented Nov 3, 2023

This is happening because the length is calculated with an ascii encoding instead of utf8.

https://github.com/Kong/httpsnippet/blob/master/src/targets/http/http1.1/client.ts#L72

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

No branches or pull requests

2 participants