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

refactor: set content-length as number with outgoing.writeHead() #105

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

yusukebe
Copy link
Member

It would be better to use number, even if it may not affect performance.

Content-Length is read in bytes, not characters. Use Buffer.byteLength() to determine the length of the body in bytes. Node.js will check whether Content-Length and the length of the body which has been transmitted are equal or not.

https://github.com/nodejs/node/blob/main/doc/api/http.md#responsewriteheadstatuscode-statusmessage-headers

@yusukebe
Copy link
Member Author

@usualoma

I think it's better, what do you think this?

@usualoma
Copy link
Member

@yusukebe
Thank you. I agree!

@yusukebe
Copy link
Member Author

Okay!

@yusukebe yusukebe merged commit e64845b into main Nov 29, 2023
3 checks passed
@yusukebe yusukebe deleted the refactor/content-length-number branch November 29, 2023 21:45
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.

2 participants