mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge branch 'develop' into key_val_lists
This commit is contained in:
@@ -91,6 +91,7 @@ if is_py2:
|
||||
from StringIO import StringIO
|
||||
from .packages import chardet
|
||||
|
||||
builtin_str = str
|
||||
bytes = str
|
||||
str = unicode
|
||||
basestring = basestring
|
||||
@@ -105,6 +106,7 @@ elif is_py3:
|
||||
from io import StringIO
|
||||
from .packages import chardet2 as chardet
|
||||
|
||||
builtin_str = str
|
||||
str = str
|
||||
bytes = bytes
|
||||
basestring = (str,bytes)
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ from .utils import (
|
||||
DEFAULT_CA_BUNDLE_PATH)
|
||||
from .compat import (
|
||||
cookielib, urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,
|
||||
StringIO, is_py2, chardet, json)
|
||||
StringIO, is_py2, chardet, json, builtin_str)
|
||||
|
||||
REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)
|
||||
CONTENT_CHUNK_SIZE = 10 * 1024
|
||||
@@ -507,7 +507,7 @@ class Request(object):
|
||||
if self.data:
|
||||
|
||||
body = self._encode_params(self.data)
|
||||
if isinstance(self.data, str) or hasattr(self.data, 'read'):
|
||||
if isinstance(self.data, str) or isinstance(self.data, builtin_str) or hasattr(self.data, 'read'):
|
||||
content_type = None
|
||||
else:
|
||||
content_type = 'application/x-www-form-urlencoded'
|
||||
|
||||
@@ -1029,5 +1029,12 @@ class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):
|
||||
self.assertEqual(t.get('form'), {'field': 'a, b'})
|
||||
self.assertEqual(t.get('files'), files)
|
||||
|
||||
def test_str_data_content_type(self):
|
||||
data = 'test string data'
|
||||
r = post(httpbin('post'), data=data)
|
||||
t = json.loads(r.text)
|
||||
self.assertEqual(t.get('headers').get('Content-Type'), '')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user