Skip to content

Commit

Permalink
默认不进行字节解码
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan committed Apr 13, 2024
1 parent 616f078 commit 9aaa9d4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 22 deletions.
10 changes: 1 addition & 9 deletions httpfpt/common/send_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from json import JSONDecodeError

import allure
import chardet
import httpx
import requests
import stamina
Expand Down Expand Up @@ -250,14 +249,7 @@ def send_request(
log.warning(err_msg)
raise SendRequestError(err_msg)
response_data['json'] = json_data
res_content = response.content
res_content_encoding = 'utf-8'
if 'charset=' in res_content_type:
res_content_encoding = res_content_type.split('charset=')[-1]
detected_encoding = chardet.detect(res_content)['encoding']
if detected_encoding and detected_encoding.lower() != res_content_encoding:
res_content_encoding = detected_encoding
response_data['content'] = response.content.decode(res_content_encoding)
response_data['content'] = response.content
response_data['text'] = response.text
response_data['request'] = request_data_parsed

Expand Down
12 changes: 1 addition & 11 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ dependencies = [
"jsonschema>=4.21.1",
"pygments>=2.17.2",
"glom>=23.5.0",
"chardet>=5.2.0",
]
requires-python = ">=3.8"
readme = "README.md"
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cappa==0.17.1
certifi==2023.11.17
cffi==1.16.0
cfgv==3.4.0
chardet==5.2.0
charset-normalizer==3.3.2
colorama==0.4.6; sys_platform == "win32"
cryptography==41.0.6
Expand Down

0 comments on commit 9aaa9d4

Please sign in to comment.