added tests for mixed-case scheme URLs, changed adapters passing down URLs into urlli...
authorViktor Haag <Viktor.Haag@Desire2Learn.com>
Fri, 24 May 2013 20:14:14 +0000 (16:14 -0400)
committerViktor Haag <Viktor.Haag@Desire2Learn.com>
Fri, 24 May 2013 20:14:14 +0000 (16:14 -0400)
requests/adapters.py
test_requests.py

index b4f5bf6..7b4916c 100644 (file)
@@ -190,13 +190,13 @@ class HTTPAdapter(BaseAdapter):
         :param proxies: (optional) A Requests-style dictionary of proxies used on this request.
         """
         proxies = proxies or {}
-        proxy = proxies.get(urlparse(url).scheme)
+        proxy = proxies.get(urlparse(url.lower()).scheme)
 
         if proxy:
-            proxy = prepend_scheme_if_needed(proxy, urlparse(url).scheme)
+            proxy = prepend_scheme_if_needed(proxy, urlparse(url.lower()).scheme)
             conn = ProxyManager(self.poolmanager.connection_from_url(proxy))
         else:
-            conn = self.poolmanager.connection_from_url(url)
+            conn = self.poolmanager.connection_from_url(url.lower())
 
         return conn
 
index 3600600..a346334 100755 (executable)
@@ -89,22 +89,29 @@ class RequestsTestCase(unittest.TestCase):
 
     def test_mixed_case_scheme_acceptable(self):
         s = requests.Session()
-        r = requests.Request('GET', 'HTTP://httbin.org/get')
+        r = requests.Request('GET', 'http://httpbin.org/get')
         r = s.send(r.prepare())
         self.assertEqual(r.status_code,200)
-        r = requests.Request('GET', 'hTTp://httbin.org/get')
+        s = requests.Session()
+        r = requests.Request('GET', 'HTTP://httpbin.org/get')
+        r = s.send(r.prepare())
+        self.assertEqual(r.status_code,200)
+        r = requests.Request('GET', 'hTTp://httpbin.org/get')
+        r = s.send(r.prepare())
+        self.assertEqual(r.status_code,200)
+        r = requests.Request('GET', 'HttP://httpbin.org/get')
         r = s.send(r.prepare())
         self.assertEqual(r.status_code,200)
-        r = requests.Request('GET', 'HttP://httbin.org/get')
+        r = requests.Request('GET', 'https://httpbin.org/get')
         r = s.send(r.prepare())
         self.assertEqual(r.status_code,200)
-        r = requests.Request('GET', 'HTTPS://httbin.org/get')
+        r = requests.Request('GET', 'HTTPS://httpbin.org/get')
         r = s.send(r.prepare())
         self.assertEqual(r.status_code,200)
-        r = requests.Request('GET', 'hTTps://httbin.org/get')
+        r = requests.Request('GET', 'hTTps://httpbin.org/get')
         r = s.send(r.prepare())
         self.assertEqual(r.status_code,200)
-        r = requests.Request('GET', 'HttPs://httbin.org/get')
+        r = requests.Request('GET', 'HttPs://httpbin.org/get')
         r = s.send(r.prepare())
         self.assertEqual(r.status_code,200)