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

Bg-dropped-reqbody-#46 #1214

Merged
merged 7 commits into from
Feb 16, 2022
Merged

Bg-dropped-reqbody-#46 #1214

merged 7 commits into from
Feb 16, 2022

Conversation

jobala
Copy link
Contributor

@jobala jobala commented Feb 15, 2022

Overview

Fixes #46

Notes

Reading from a buffer drains the buffer ie, the buffer will be empty after reading all the bytes in it. The bug occured because req.Body was passed to compressReqBody after its contents had been read at line 69 which means whatever compressReqBody received was empty.

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

thanks for looking into that. one minor question on my side.
Can you also update the changelog please?

@@ -42,24 +42,6 @@ func TestCompressionHandlerAddsContentEncodingHeader(t *testing.T) {
assert.Equal(t, contentTypeHeader, "gzip")
}

func TestCompressionHandlerCompressesRequestBody(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

can you expand on why you decided to remove that test please?

Copy link
Contributor Author

@jobala jobala Feb 15, 2022

Choose a reason for hiding this comment

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

It is not always true that the compressed body will be smaller than the uncompressed body for small payloads.

Copy link
Member

Choose a reason for hiding this comment

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

thanks for the precision here. We should still check the compression is actually performing compression work in case somebody breaks it in the future. hardcoding the expected size of the result would be ok for that purpose I think.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@baywet baywet merged commit 2851572 into main Feb 16, 2022
@baywet baywet deleted the bg-dropped-reqbody-#46 branch February 16, 2022 12:14
@baywet baywet added this to the Community Preview milestone Feb 16, 2022
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.

Empty Payload When Making Post Requests
2 participants