mirror of
https://github.com/httpie/cli.git
synced 2025-06-23 11:01:32 +02:00
Drop sequence length check
This commit is contained in:
parent
252fe02f74
commit
d52a4833e4
@ -1,7 +1,6 @@
|
|||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from charset_normalizer import from_bytes
|
from charset_normalizer import from_bytes
|
||||||
from charset_normalizer.constant import TOO_SMALL_SEQUENCE
|
|
||||||
|
|
||||||
UTF8 = 'utf-8'
|
UTF8 = 'utf-8'
|
||||||
|
|
||||||
@ -16,13 +15,11 @@ def detect_encoding(content: ContentBytes) -> str:
|
|||||||
>>> too_short = ']"foo"'
|
>>> too_short = ']"foo"'
|
||||||
>>> detected = from_bytes(too_short.encode()).best().encoding
|
>>> detected = from_bytes(too_short.encode()).best().encoding
|
||||||
>>> detected
|
>>> detected
|
||||||
'utf_16_be'
|
'ascii'
|
||||||
>>> too_short.encode().decode(detected)
|
>>> too_short.encode().decode(detected)
|
||||||
'崢景漢'
|
']"foo"'
|
||||||
|
|
||||||
"""
|
"""
|
||||||
encoding = UTF8
|
encoding = UTF8
|
||||||
if len(content) > TOO_SMALL_SEQUENCE:
|
|
||||||
match = from_bytes(bytes(content)).best()
|
match = from_bytes(bytes(content)).best()
|
||||||
if match:
|
if match:
|
||||||
encoding = match.encoding
|
encoding = match.encoding
|
||||||
|
2
setup.py
2
setup.py
@ -25,7 +25,7 @@ dev_require = [
|
|||||||
'wheel',
|
'wheel',
|
||||||
]
|
]
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'charset_normalizer>=2.0.0',
|
'charset_normalizer>=2.0.5',
|
||||||
'defusedxml>=0.6.0',
|
'defusedxml>=0.6.0',
|
||||||
'requests[socks]>=2.22.0',
|
'requests[socks]>=2.22.0',
|
||||||
'Pygments>=2.5.2',
|
'Pygments>=2.5.2',
|
||||||
|
@ -4,7 +4,6 @@ Various unicode handling related tests.
|
|||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
import responses
|
import responses
|
||||||
from charset_normalizer.constant import TOO_SMALL_SEQUENCE
|
|
||||||
|
|
||||||
from httpie.cli.constants import PRETTY_MAP
|
from httpie.cli.constants import PRETTY_MAP
|
||||||
from httpie.encoding import UTF8
|
from httpie.encoding import UTF8
|
||||||
@ -13,8 +12,7 @@ from .utils import http, HTTP_OK, URL_EXAMPLE, MockEnvironment, StdinBytesIO
|
|||||||
from .fixtures import UNICODE
|
from .fixtures import UNICODE
|
||||||
|
|
||||||
|
|
||||||
CZECH_TEXT = 'Všichni lidé jsou si rovni. Všichni lidé jsou si rovni.'
|
CZECH_TEXT = 'Všichni lidé jsou si rovni.'
|
||||||
assert len(CZECH_TEXT) > TOO_SMALL_SEQUENCE
|
|
||||||
CZECH_TEXT_SPECIFIC_CHARSET = 'windows-1250'
|
CZECH_TEXT_SPECIFIC_CHARSET = 'windows-1250'
|
||||||
ENCODINGS = [UTF8, CZECH_TEXT_SPECIFIC_CHARSET]
|
ENCODINGS = [UTF8, CZECH_TEXT_SPECIFIC_CHARSET]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user