- fixed func call syntax on lower to lower()

- added test cases for trying to test GETS on mixed-case schemas
This commit is contained in:
Viktor Haag
2013-05-24 14:01:30 -04:00
parent 3004ad5398
commit 5e94f38001
3 changed files with 23 additions and 2 deletions
+1 -1
View 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
+1 -1
View 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 :-/
+21
View File
@@ -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()