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

Improve parsing in readBody #889

Open
1 task done
itpropro opened this issue Sep 26, 2024 · 0 comments
Open
1 task done

Improve parsing in readBody #889

itpropro opened this issue Sep 26, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@itpropro
Copy link
Member

Describe the feature

I would propose the following optimizations in readBody and would like to know what you think about that @pi0

  • Instead of first calling response.text(), use the content-length header to determine if a body is existent (Transfer-Encoding: chunked and form data shouldn't be relevant here, as they have their own helpers)
  • Then check the content-type header and call parseURLEncodedBody on request.text() if applies
  • Otherwise directly return response.json() instead of passing text to JSON.parse as destr was removed anyway

This would avoid memory overhead for large files and could also enable file/request size limits, which are normally based on the content-length header (DOS protection). Although there might be better places for content-length validation.

Additional information

  • Would you be willing to help implement this feature?
@itpropro itpropro added the enhancement New feature or request label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant