mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Fix regression from #2844 regarding binary bodies.
This commit is contained in:
+4
-1
@@ -81,7 +81,7 @@ class RequestEncodingMixin(object):
|
||||
"""
|
||||
|
||||
if isinstance(data, (str, bytes)):
|
||||
return to_native_string(data)
|
||||
return data
|
||||
elif hasattr(data, 'read'):
|
||||
return data
|
||||
elif hasattr(data, '__iter__'):
|
||||
@@ -385,6 +385,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
||||
if isinstance(fragment, str):
|
||||
fragment = fragment.encode('utf-8')
|
||||
|
||||
if isinstance(params, (str, bytes)):
|
||||
params = to_native_string(params)
|
||||
|
||||
enc_params = self._encode_params(params)
|
||||
if enc_params:
|
||||
if query:
|
||||
|
||||
@@ -157,6 +157,11 @@ class TestRequests(object):
|
||||
params=b'test=foo').prepare()
|
||||
assert request.url == 'http://example.com/?test=foo'
|
||||
|
||||
def test_binary_put(self):
|
||||
request = requests.Request('PUT', 'http://example.com',
|
||||
data=u"ööö".encode("utf-8")).prepare()
|
||||
assert isinstance(request.body, bytes)
|
||||
|
||||
def test_mixed_case_scheme_acceptable(self, httpbin):
|
||||
s = requests.Session()
|
||||
s.proxies = getproxies()
|
||||
|
||||
Reference in New Issue
Block a user