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

fix: support gzip decompression on metadata requests #383

Merged
merged 3 commits into from
Aug 5, 2022

Conversation

cojenco
Copy link
Contributor

@cojenco cojenco commented Jul 22, 2022

Fixes #379

Adds gzip decompression support using the before_request decorator

  • adds gzip decompression when Content-Encoding: "gzip" is present in request headers
  • no decompression when object's metadata includes contentEncoding: "gzip" in upload requests so that we can store data compressed when applicable and preserve decompressive transcoding improvements made in fix: decompressive transcoding improvements #322

@codecov
Copy link

codecov bot commented Jul 22, 2022

Codecov Report

Merging #383 (dc33c76) into main (1051888) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #383      +/-   ##
==========================================
+ Coverage   92.25%   92.28%   +0.03%     
==========================================
  Files          51       51              
  Lines        8202     8235      +33     
==========================================
+ Hits         7567     7600      +33     
  Misses        635      635              
Flag Coverage Δ
unittests 92.28% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
testbench/common.py 98.51% <100.00%> (+0.01%) ⬆️
testbench/rest_server.py 98.62% <100.00%> (+0.01%) ⬆️
testbench/servers/iam_rest_server.py 100.00% <100.00%> (ø)
testbench/servers/projects_rest_server.py 100.00% <100.00%> (ø)
tests/test_common.py 99.79% <100.00%> (+<0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@cojenco cojenco marked this pull request as ready for review August 4, 2022 22:45
@cojenco cojenco requested review from a team and coryan as code owners August 4, 2022 22:45
@cojenco cojenco requested a review from frankyn August 4, 2022 22:53
Copy link
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

LGTM, but frankly it is a bit of a rubber stamp. If you need somebody who actually understands what is going on, maybe ask @frankyn?

@frankyn
Copy link
Contributor

frankyn commented Aug 5, 2022

I'm working with @cojenco, thanks @coryan!

This helps resolves most of the issues; I still see failures for HmacKey requests though;

com.google.cloud.storage.StorageException: Traceback (most recent call last):
  File "/home/franknatividad/Documents/storage-testbench/test/lib/python3.8/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/franknatividad/Documents/storage-testbench/test/lib/python3.8/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/franknatividad/Documents/storage-testbench/testbench/common.py", line 797, in wrapper
    return response_handler(func(*args, **kwargs))
  File "/home/franknatividad/Documents/storage-testbench/testbench/servers/projects_rest_server.py", line 108, in hmac_keys_update
    payload = json.loads(flask.request.data)
  File "/home/franknatividad/.pyenv/versions/3.8.0/lib/python3.8/json/__init__.py", line 343, in loads
    s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

@cojenco
Copy link
Contributor Author

cojenco commented Aug 5, 2022

Thanks @coryan @frankyn for checking!

I've applied the same decorator to both the projects and iam servers. Hopefully this should resolve the remaining issues.

Copy link
Contributor

@frankyn frankyn left a comment

Choose a reason for hiding this comment

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

Thank you @cojenco that helped resolve the failures in the Java conf tests. Cheers!

@frankyn frankyn merged commit adeb2cc into googleapis:main Aug 5, 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.

Support gzip compressed JSON bodies in rest testbench
3 participants