merge 2.0 insto master
authorKenneth Reitz <me@kennethreitz.com>
Tue, 24 Sep 2013 18:13:28 +0000 (14:13 -0400)
committerKenneth Reitz <me@kennethreitz.com>
Tue, 24 Sep 2013 18:13:28 +0000 (14:13 -0400)
1  2 
AUTHORS.rst
README.rst
requests/adapters.py
requests/models.py
requests/sessions.py
requests/utils.py
test_requests.py

diff --cc AUTHORS.rst
@@@ -133,5 -133,4 +133,6 @@@ Patches and Suggestion
  - Kevin Burke <kev@inburke.com>
  - Flavio Curella
  - David Pursehouse <david.pursehouse@gmail.com> @dpursehouse
 -- Marc Schlaich @schlamar
 +- Jon Parise
 +- Alexander Karpinsky @homm86
++- Marc Schlaich @schlamar
diff --cc README.rst
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -645,51 -653,25 +660,69 @@@ class RequestsTestCase(unittest.TestCas
          r = requests.Request('GET', url).prepare()
          self.assertEqual(r.url, url)
  
+     def test_header_keys_are_native(self):
+         headers = {u'unicode': 'blah', 'byte'.encode('ascii'): 'blah'}
+         r = requests.Request('GET', httpbin('get'), headers=headers)
+         p = r.prepare()
+         # This is testing that they are builtin strings. A bit weird, but there
+         # we go.
+         self.assertTrue('unicode' in p.headers.keys())
+         self.assertTrue('byte' in p.headers.keys())
+     def test_can_send_nonstring_objects_with_files(self):
+         data = {'a': 0.0}
+         files = {'b': 'foo'}
+         r = requests.Request('POST', httpbin('post'), data=data, files=files)
+         p = r.prepare()
+         self.assertTrue('multipart/form-data' in p.headers['Content-Type'])
  
 +class TestContentEncodingDetection(unittest.TestCase):
 +
 +    def test_none(self):
 +        encodings = requests.utils.get_encodings_from_content('')
 +        self.assertEqual(len(encodings), 0)
 +
 +    def test_html_charset(self):
 +        """HTML5 meta charset attribute"""
 +        content = '<meta charset="UTF-8">'
 +        encodings = requests.utils.get_encodings_from_content(content)
 +        self.assertEqual(len(encodings), 1)
 +        self.assertEqual(encodings[0], 'UTF-8')
 +
 +    def test_html4_pragma(self):
 +        """HTML4 pragma directive"""
 +        content = '<meta http-equiv="Content-type" content="text/html;charset=UTF-8">'
 +        encodings = requests.utils.get_encodings_from_content(content)
 +        self.assertEqual(len(encodings), 1)
 +        self.assertEqual(encodings[0], 'UTF-8')
 +
 +    def test_xhtml_pragma(self):
 +        """XHTML 1.x served with text/html MIME type"""
 +        content = '<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />'
 +        encodings = requests.utils.get_encodings_from_content(content)
 +        self.assertEqual(len(encodings), 1)
 +        self.assertEqual(encodings[0], 'UTF-8')
 +
 +    def test_xml(self):
 +        """XHTML 1.x served as XML"""
 +        content = '<?xml version="1.0" encoding="UTF-8"?>'
 +        encodings = requests.utils.get_encodings_from_content(content)
 +        self.assertEqual(len(encodings), 1)
 +        self.assertEqual(encodings[0], 'UTF-8')
 +
 +    def test_precedence(self):
 +        content = '''
 +        <?xml version="1.0" encoding="XML"?>
 +        <meta charset="HTML5">
 +        <meta http-equiv="Content-type" content="text/html;charset=HTML4" />
 +        '''.strip()
 +        encodings = requests.utils.get_encodings_from_content(content)
 +        self.assertEqual(encodings, ['HTML5', 'HTML4', 'XML'])
 +
 +
  class TestCaseInsensitiveDict(unittest.TestCase):
  
      def test_mapping_init(self):