Merge branch 'develop' into key_val_lists

This commit is contained in:
Ian Cordasco
2012-08-05 16:59:24 -04:00
3 changed files with 11 additions and 2 deletions
+2
View File
@@ -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
View File
@@ -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'
+7
View File
@@ -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()