Skip to content

Commit 4d3f092

Browse files
refactor
1 parent 0655c82 commit 4d3f092

3 files changed

Lines changed: 1 addition & 9 deletions

File tree

google-cloud-storage/acceptance/storage/bucket_test.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,9 @@
268268
end
269269

270270
it "omits Accept-Encoding: gzip header for file uploads" do
271-
# Verify the service's global headers do not contain the gzip encoding
272271
global_headers = storage.service.service.request_options.header || {}
273272
_(global_headers["Accept-Encoding"]).wont_equal "gzip"
274273

275-
# By uploading a JSON file, we simulate the bug condition.
276-
# If the header were sent globally, the server might return gzipped JSON metadata, causing a parse error.
277274
uploaded = bucket.create_file StringIO.new('{"metadata":"test"}'), "test-upload-metadata.json", content_type: "application/json"
278275

279276
_(uploaded.name).must_equal "test-upload-metadata.json"

google-cloud-storage/acceptance/storage/file_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,9 @@
4343
end
4444

4545
it "does not send Accept-Encoding: gzip globally during file uploads" do
46-
# Verify the service's global headers do not contain the gzip encoding
4746
global_headers = storage.service.service.request_options.header || {}
4847
_(global_headers["Accept-Encoding"]).wont_equal "gzip"
4948

50-
# By uploading a JSON file, we simulate the bug condition.
51-
# If the header was sent, the server might return gzipped JSON metadata,
52-
# which the upload method wouldn't know how to parse, causing an error.
5349
uploaded = bucket.create_file StringIO.new('{"metadata":"test"}'), "upload-metadata.json", content_type: "application/json"
5450
_(uploaded.name).must_equal "upload-metadata.json"
5551
uploaded.delete

google-cloud-storage/lib/google/cloud/storage/service.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,7 @@ def download_file bucket_name, file_path, target_path, generation: nil,
585585
key: nil, range: nil, user_project: nil, options: {}
586586
options = key_options(key).merge(options)
587587
options = range_header options, range
588-
options[:header] ||= {}
589-
options[:header]["Accept-Encoding"] = "gzip"
588+
options[:header] = (options[:header] || {}).merge("Accept-Encoding" => "gzip")
590589

591590
execute do
592591
service.get_object \

0 commit comments

Comments
 (0)