mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 20:53:13 -06:00
Patched urllib3 included in requests to avoid encoding audio filenames
This commit is contained in:
parent
2c58645e02
commit
212f49df08
@ -1,5 +1,22 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from requests.packages import urllib3
|
from requests.packages import urllib3
|
||||||
|
from requests.packages.urllib3 import fields
|
||||||
|
import six
|
||||||
|
|
||||||
def fix():
|
def fix():
|
||||||
urllib3.disable_warnings()
|
urllib3.disable_warnings()
|
||||||
|
fields.format_header_param=patched_format_header_param
|
||||||
|
|
||||||
|
def patched_format_header_param(name, value):
|
||||||
|
if not any(ch in value for ch in '"\\\r\n'):
|
||||||
|
result = '%s="%s"' % (name, value)
|
||||||
|
try:
|
||||||
|
result.encode('ascii')
|
||||||
|
except (UnicodeEncodeError, UnicodeDecodeError):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return result
|
||||||
|
if not six.PY3 and isinstance(value, six.text_type): # Python 2:
|
||||||
|
value = value.encode('utf-8')
|
||||||
|
value = '%s=%s' % (name, value)
|
||||||
|
return value
|
||||||
|
Loading…
Reference in New Issue
Block a user