Merge pull request #1531 from Schamper/encoding-patch

Fix decoding when content-encoding: none
This commit is contained in:
Thomas Kriechbaumer 2016-09-06 20:29:59 +02:00 committed by GitHub
commit 7841d73cb2
2 changed files with 9 additions and 3 deletions

View File

@ -162,12 +162,14 @@ def encode_deflate(content):
custom_decode = {
"none": identity,
"identity": identity,
"gzip": decode_gzip,
"deflate": decode_deflate,
"br": decode_brotli,
}
custom_encode = {
"none": identity,
"identity": identity,
"gzip": encode_gzip,
"deflate": encode_deflate,

View File

@ -4,9 +4,13 @@ import pytest
from netlib import encoding, tutils
def test_identity():
assert b"string" == encoding.decode(b"string", "identity")
assert b"string" == encoding.encode(b"string", "identity")
@pytest.mark.parametrize("encoder", [
'identity',
'none',
])
def test_identity(encoder):
assert b"string" == encoding.decode(b"string", encoder)
assert b"string" == encoding.encode(b"string", encoder)
with tutils.raises(ValueError):
encoding.encode(b"string", "nonexistent encoding")