You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_recorder.record captures header 'content-encoding: gzip' but does not return gzip content on replay #724
headers has been added to the recording file which may include content-encoding. When a recording with content-encoding: gzip is replayed an error is received:
urllib3.exceptions.DecodeError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect header check'))
Additional context
No response
Version of responses
0.25.3
Steps to Reproduce
# Recording code@_recorder.record(file_path="out.yaml")defrecord():
# call lookup API
- response:
auto_calculate_content_length: falsebody: '[{"first_name":true,"last_name":true,"email":false,"phone_number":false,"custom_id":true,"user_id":"abc123","status":{"code":"ACTIVE","description":"The user is fully active with all features enabled. Further restrictions may apply for some features."},"employers":[{"id":"abc123","sso_required":false}]}]'content_type: text/plainheaders:
API-Version: '1'X-Dep-Next: T-0.8.4X-Download-Options: noopenX-Permitted-Cross-Domain-Policies: noneX-Request-Id: f8903c30-4fb2-4b30-95b1-b20e0fdfb515X-Runtime: '0.129368'apigw-requestid: Z0iA3ibpIAMEaxg=cache-control: max-age=0, private, must-revalidatecontent-encoding: gzipetag: W/"2b965752b6adbb3fd7467a489ad314b0"referrer-policy: strict-origin-when-cross-originvary: Accept-Encoding, Originx-content-type-options: nosniffx-frame-options: SAMEORIGINx-xss-protection: '0'method: GETstatus: 200url: https://api.com/v1/users/lookup?custom_id=060419806551&last_name=Murphy&first_name=Lucy
# Test code@responses.activatedeftest_lookup_api():
responses._add_from_file(file_path="out.yaml")
lookup=# call lookup APIassertlookup["first_name"] ==True
Expected Result
Pass
Actual Result
urllib3.exceptions.DecodeError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect header check'))
Storing gzip data in yaml files feels gross. Removing the content-encoding header and storing the response body as str/bytes seems more human-friendly to me.
Activity
markstory commentedon Jun 24, 2024
Storing gzip data in yaml files feels gross. Removing the
content-encodingheader and storing the response body as str/bytes seems more human-friendly to me.