-
Notifications
You must be signed in to change notification settings - Fork 321
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
Inflater handle empty streams #625
Inflater handle empty streams #625
Conversation
@LukaszMaslej seems like a reasonable enough workaround, although there are some RuboCop failures |
lib/http/response/inflater.rb
Outdated
@@ -16,7 +16,7 @@ def readpartial(*args) | |||
if chunk | |||
chunk = zstream.inflate(chunk) | |||
elsif !zstream.closed? | |||
zstream.finish | |||
zstream.finish if zstream.total_in > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RuboCop suggests the following here:
zstream.finish if zstream.total_in > 0 | |
zstream.finish if zstream.total_in.positive? |
spec/support/dummy_server/servlet.rb
Outdated
res.body = case req["Accept-Encoding"] | ||
when "gzip" then | ||
res["Content-Encoding"] = "gzip" | ||
"" | ||
when "deflate" then | ||
res["Content-Encoding"] = "deflate" | ||
"" | ||
else | ||
"" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RuboCop suggests moving the ""
out of the conditional since it's the same for all branches
res.body = case req["Accept-Encoding"] | |
when "gzip" then | |
res["Content-Encoding"] = "gzip" | |
"" | |
when "deflate" then | |
res["Content-Encoding"] = "deflate" | |
"" | |
else | |
"" | |
end | |
res.body = "" | |
case req["Accept-Encoding"] | |
when "gzip" then | |
res["Content-Encoding"] = "gzip" | |
when "deflate" then | |
res["Content-Encoding"] = "deflate" | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tarcieri fair suggestions, fixed.
7484c86
to
025e9b4
Compare
The test failures appear to be unrelated. Thanks for the fix! |
Hello,
This prevents the issue of Zlib::BufError errors raised when reading
by Inflater empty streams (should fix #624).
Thanks!