- fixed func call syntax on lower to lower()
authorViktor Haag <Viktor.Haag@Desire2Learn.com>
Fri, 24 May 2013 18:01:30 +0000 (14:01 -0400)
committerViktor Haag <Viktor.Haag@Desire2Learn.com>
Fri, 24 May 2013 18:01:30 +0000 (14:01 -0400)
- added test cases for trying to test GETS on mixed-case schemas

requests/adapters.py
requests/sessions.py
test_requests.py

index b450279..b4f5bf6 100644 (file)
@@ -118,7 +118,7 @@ class HTTPAdapter(BaseAdapter):
         :param verify: Whether we should actually verify the certificate.
         :param cert: The SSL certificate to verify.
         """
-        if url.lower.startswith('https') and verify:
+        if url.lower().startswith('https') and verify:
 
             cert_loc = None
 
index ccd7634..a55f84d 100644 (file)
@@ -467,7 +467,7 @@ class Session(SessionRedirectMixin):
         """Returns the appropriate connnection adapter for the given URL."""
         for (prefix, adapter) in self.adapters.items():
 
-            if url.lower.startswith(prefix):
+            if url.lower().startswith(prefix):
                 return adapter
 
         # Nothing matches :-/
index 4a4831e..3600600 100755 (executable)
@@ -87,6 +87,27 @@ class RequestsTestCase(unittest.TestCase):
         self.assertEqual(request.url,
             "http://example.com/path?key=value&a=b#fragment")
 
+    def test_mixed_case_scheme_acceptable(self):
+        s = requests.Session()
+        r = requests.Request('GET', 'HTTP://httbin.org/get')
+        r = s.send(r.prepare())
+        self.assertEqual(r.status_code,200)
+        r = requests.Request('GET', 'hTTp://httbin.org/get')
+        r = s.send(r.prepare())
+        self.assertEqual(r.status_code,200)
+        r = requests.Request('GET', 'HttP://httbin.org/get')
+        r = s.send(r.prepare())
+        self.assertEqual(r.status_code,200)
+        r = requests.Request('GET', 'HTTPS://httbin.org/get')
+        r = s.send(r.prepare())
+        self.assertEqual(r.status_code,200)
+        r = requests.Request('GET', 'hTTps://httbin.org/get')
+        r = s.send(r.prepare())
+        self.assertEqual(r.status_code,200)
+        r = requests.Request('GET', 'HttPs://httbin.org/get')
+        r = s.send(r.prepare())
+        self.assertEqual(r.status_code,200)
+
     def test_HTTP_200_OK_GET_ALTERNATIVE(self):
         r = requests.Request('GET', httpbin('get'))
         s = requests.Session()