only adjust the request encoding on py3
This commit is contained in:
parent
3e595b0244
commit
0b5a0d691f
1 changed files with 8 additions and 11 deletions
|
|
@ -2426,17 +2426,14 @@ class ClientSession(object):
|
|||
else:
|
||||
handler = self.baseurl
|
||||
request = dumps(args, name, allow_none=1)
|
||||
try:
|
||||
request.encode('latin-1')
|
||||
except UnicodeEncodeError:
|
||||
# if string is not converted to UTF, requests will raise an error
|
||||
# on identical check before sending data
|
||||
# py3 string throws UnicodeEncodeError
|
||||
request = request.encode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
# py2 string throws UnicodeDecodeError, but it is already meant
|
||||
# to sent as-is
|
||||
pass
|
||||
if six.PY3:
|
||||
try:
|
||||
request.encode('latin-1')
|
||||
except UnicodeEncodeError:
|
||||
# if string is not converted to UTF, requests will raise an error
|
||||
# on identical check before sending data
|
||||
# py3 string throws UnicodeEncodeError
|
||||
request = request.encode('utf-8')
|
||||
headers = [
|
||||
# connection class handles Host
|
||||
('User-Agent', 'koji/1'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue