mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
Merge pull request #4741 from Mattwmaster58/main
case insensitive encoding
This commit is contained in:
commit
ab6f1ebb44
@ -1,5 +1,9 @@
|
||||
# Release History
|
||||
|
||||
## Unreleased: mitmproxy next
|
||||
|
||||
* fix some responses not being decoded properly if the encoding was uppercase #4735 (@Mattwmaster58)
|
||||
|
||||
## 4 August 2021: mitmproxy 7.0.2
|
||||
|
||||
* Fix a WebSocket crash introduced in 7.0.1 (@mhils)
|
||||
|
@ -52,6 +52,7 @@ def decode(
|
||||
"""
|
||||
if encoded is None:
|
||||
return None
|
||||
encoding = encoding.lower()
|
||||
|
||||
global _cache
|
||||
cached = (
|
||||
@ -67,7 +68,7 @@ def decode(
|
||||
decoded = custom_decode[encoding](encoded)
|
||||
except KeyError:
|
||||
decoded = codecs.decode(encoded, encoding, errors) # type: ignore
|
||||
if encoding in ("gzip", "deflate", "br", "zstd"):
|
||||
if encoding in ("gzip", "deflate", "deflateraw", "br", "zstd"):
|
||||
_cache = CachedDecode(encoded, encoding, errors, decoded)
|
||||
return decoded
|
||||
except TypeError:
|
||||
@ -108,6 +109,7 @@ def encode(decoded: Union[None, str, bytes], encoding, errors='strict') -> Union
|
||||
"""
|
||||
if decoded is None:
|
||||
return None
|
||||
encoding = encoding.lower()
|
||||
|
||||
global _cache
|
||||
cached = (
|
||||
@ -123,7 +125,7 @@ def encode(decoded: Union[None, str, bytes], encoding, errors='strict') -> Union
|
||||
encoded = custom_encode[encoding](decoded)
|
||||
except KeyError:
|
||||
encoded = codecs.encode(decoded, encoding, errors) # type: ignore
|
||||
if encoding in ("gzip", "deflate", "br", "zstd"):
|
||||
if encoding in ("gzip", "deflate", "deflateraw", "br", "zstd"):
|
||||
_cache = CachedDecode(encoded, encoding, errors, decoded)
|
||||
return encoded
|
||||
except TypeError:
|
||||
@ -216,7 +218,7 @@ custom_decode = {
|
||||
"identity": identity,
|
||||
"gzip": decode_gzip,
|
||||
"deflate": decode_deflate,
|
||||
"deflateRaw": decode_deflate,
|
||||
"deflateraw": decode_deflate,
|
||||
"br": decode_brotli,
|
||||
"zstd": decode_zstd,
|
||||
}
|
||||
@ -225,7 +227,7 @@ custom_encode = {
|
||||
"identity": identity,
|
||||
"gzip": encode_gzip,
|
||||
"deflate": encode_deflate,
|
||||
"deflateRaw": encode_deflate,
|
||||
"deflateraw": encode_deflate,
|
||||
"br": encode_brotli,
|
||||
"zstd": encode_zstd,
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ def test_identity(encoder):
|
||||
|
||||
@pytest.mark.parametrize("encoder", [
|
||||
'gzip',
|
||||
'GZIP',
|
||||
'br',
|
||||
'deflate',
|
||||
'zstd',
|
||||
|
Loading…
Reference in New Issue
Block a user