fix problem with path being double escaped
authorDavid Kemp (Work) <dkemp@brilliantmedia.co.uk>
Wed, 25 Jan 2012 16:21:07 +0000 (16:21 +0000)
committerDavid Kemp (Work) <dkemp@brilliantmedia.co.uk>
Wed, 25 Jan 2012 16:21:07 +0000 (16:21 +0000)
requests/models.py
test_requests.py

index 82c7572995a7e13eab2478f0a089b1b2f2259bab..c2cbe979184dfb74a49d178bbb8a252431f8a91b 100644 (file)
@@ -351,8 +351,8 @@ class Request(object):
         if not path:
             path = '/'
 
-        if is_py3:
-        path = quote(path.encode('utf-8'))
+        if is_py3:
+            path = quote(path.encode('utf-8'))
 
         url.append(path)
 
index 034f469c5b959a2bd33c48156829357eab5df799..c3f3deb646ebac7d86e8478b224df974d2547cd1 100644 (file)
@@ -72,6 +72,12 @@ class RequestsTestSuite(TestSetup, unittest.TestCase):
     def test_invalid_url(self):
         self.assertRaises(ValueError, get, 'hiwpefhipowhefopw')
 
+
+    def test_path_is_not_double_encoded(self):
+        request = requests.Request("http://0.0.0.0/get/~test")
+
+        assert request.path_url == "/get/%7Etest"
+
     def test_HTTP_200_OK_GET(self):
         r = get(httpbin('/get'))
         self.assertEqual(r.status_code, 200)