Skip to content

Commit

Permalink
More reliable gzip detection
Browse files Browse the repository at this point in the history
  • Loading branch information
krschacht committed Jan 26, 2025
1 parent e0f9ad7 commit 68eef6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/services/sdk/verb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ def possible_test_warning(verb)
end

def decompress_body(response)
return response.body unless response.headers["content-encoding"] == "gzip"
Zlib::GzipReader.new(StringIO.new(response.body)).read
return response.body unless response.respond_to?(:headers) &&
response.headers["content-encoding"] == "gzip" &&
response.body.bytes[0..1] == [0x1f, 0x8b]
begin
Zlib::GzipReader.new(StringIO.new(response.body)).read
rescue Zlib::GzipFile::Error
response.body
end
end
end
2 changes: 1 addition & 1 deletion app/services/toolbox/google_tasks/api_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_lists
end

def get_list(title)
list = get_lists.find { |l| l.title == title }
list = get_lists&.find { |l| l.title == title }
raise "Could not find a task list named '#{title}'" if list.nil?
list
end
Expand Down

0 comments on commit 68eef6a

Please sign in to comment.