fix utf8 issue of http headers

pull/266/head
butaixianran 2023-09-27 11:51:27 +08:00
parent fe030dcb1b
commit f9ad4aef10
3 changed files with 6 additions and 2 deletions

View File

@ -206,6 +206,9 @@ Since v1.5.5, we've already optimized the SHA256 function to the top. So the onl
# Change Log
## v1.8.1
* fix http headers' utf8 issue for downloading
## v1.8.0
* Add remove model button

View File

@ -41,7 +41,8 @@ def dl(url, folder, filename, filepath):
if not file_path:
filename = ""
if "Content-Disposition" in rh.headers.keys():
cd = rh.headers["Content-Disposition"]
# headers default is decoded with latin1, so need to re-decode it with utf-8
cd = rh.headers["Content-Disposition"].encode('latin1').decode('utf-8', errors='ignore')
# Extract the filename from the header
# content of a CD: "attachment;filename=FileName.txt"
# in case "" is in CD filename's start and end, need to strip them out

View File

@ -6,7 +6,7 @@ import requests
import shutil
version = "1.8.0"
version = "1.8.1"
def_headers = {'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'}