BaseHTTPResponse.read() has a decode_content parameter to let the user choose between... decoding the content or not. (I'm not sure why the word is "decode" because what we're really doing is decompressing. Anyway.)
Until #2712 and #2798, issuing read() calls with differing values of decode_content would be really weird but you would not loose any data. Now that we have a buffer, issuing decode_content=False after having issued decode_content=True will cause bugs:
- if you have enough decoded data in the buffer for a read(amt, decode_content=False) you will get decoded data
- if you don't have enough data, the existing data in the buffer will be silently ignored and lost
I don't think there's an use case here to support, but should we actively prevent this footgun?
Minimum requirements
💵 You can get paid to complete this issue! Please read the docs for more information.
BaseHTTPResponse.read()has adecode_contentparameter to let the user choose between... decoding the content or not. (I'm not sure why the word is "decode" because what we're really doing is decompressing. Anyway.)Until #2712 and #2798, issuing read() calls with differing values of decode_content would be really weird but you would not loose any data. Now that we have a buffer, issuing
decode_content=Falseafter having issueddecode_content=Truewill cause bugs:I don't think there's an use case here to support, but should we actively prevent this footgun?
Minimum requirements
💵 You can get paid to complete this issue! Please read the docs for more information.
HTTPResponse.read(decode_content=True)orHTTPResponse.read(decode_content=False)should continue working as before.HTTPResponse.read(decode_content=True)followed byHTTPResponse.read(decode_content=False)should raise a RuntimeError. The other way is fine.