Check Content-Length against minSize and passthrough writes if no gzip#71
Merged
Conversation
Currently there's no way to generate a HEAD response with the correct headers as the GET unless you set the minSize as 0, but then gzip headers will be written in Close. Instead, allow a Write(nil) that will set the correct headers based on the Content-Length/Content-Type headers and only initialize a writer if there is a non-zero-length Write. If the Content-Length cannot be determined, you cannot generate the response because it cannot know if minSize would've been met. Additionally, if we determined that the request should not be compressed we should passthrough writes immediately rather than waiting until Close. Fixes #70 Fixes #64
Contributor
Author
|
I also handled the issue mentioned in #64. The benchmarks seem to show the |
Contributor
Author
|
@jprobinson Not sure if I should @ you or if you get notifications from PRs. Thanks! |
Contributor
|
@fastest963 Hi! Sorry, I've been a bit busy. I've seen this but will need to find some time to review the PR. I'll try and get to it soon. |
Contributor
Author
|
@jprobinson okay, thanks! No problem, just wanted to check on it! |
jprobinson
approved these changes
Aug 14, 2018
Contributor
jprobinson
left a comment
There was a problem hiding this comment.
🤐 🌮 !
This looks pretty good! Sorry it took me so long to review it.
Contributor
|
thanks again, @fastest963! |
Contributor
Author
|
No problem! Thanks for merging! |
jprobinson
pushed a commit
that referenced
this pull request
Aug 16, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently there's no way to generate a HEAD response with the correct
headers as the GET unless you set the minSize as 0, but then gzip headers
will be written in Close. Instead, allow a Write(nil) that will set the
correct headers based on the Content-Length/Content-Type headers and only
initialize a writer if there is a non-zero-length Write. If the
Content-Length cannot be determined, you cannot generate the response
because it cannot know if minSize would've been met.
Fixes #70