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

✨ Added decompression cases for Body function #1402

Merged

Conversation

sneakykiwi
Copy link
Contributor

@sneakykiwi sneakykiwi commented Jun 23, 2021

Please provide enough information so that others can review your pull request:

According to this issue I created a bit earlier #1401, I have implemented a filter to return the correct body each time the Body function of the fiber.Ctx struct is called

Explain the details for making this change. What existing problem does the pull request solve?
Fasthttp provides by default methods for decompressing different request payloads, currently, gofiber directly returns the raw body, if the body is compressed using gzip/deflate/brotli then it gets returned like that and the users has to decompress it manually. This PR fixes this issue

  • Added a switch for the encoding to be able to determine what type it is and how to decompress it. Usage remains the same nonetheless.
  • Updated tests and added new benchmark for updates

I have also updated the tests accordingly

improve Body function
improve performance
@ReneWerner87 ReneWerner87 merged commit 2703e92 into gofiber:master Jun 24, 2021
@welcome
Copy link

welcome bot commented Jun 24, 2021

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@navossoc
Copy link
Contributor

I saw this update yesterday when I updated my project....

// Body contains the raw body submitted in a POST request.
// Returned value is only valid within the handler. Do not store any references.
// Make copies or use the Immutable setting instead.

I think this is no longer true then...
Also the len(c.Body()) is not the Content-Length anymore.

This also broken for who doesn't want to deal with the uncompressed data.
Let's say I just want do receive it and store it.

Anyway, just mentioning a few points that come to my mind.

[]'s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Add automatic decompression for gzip, deflate, brotli
5 participants