Skip to content

Commit

Permalink
- fixed func call syntax on lower to lower()
Browse files Browse the repository at this point in the history
- added test cases for trying to test GETS on mixed-case schemas
  • Loading branch information
ViktorHaag committed May 24, 2013
1 parent 3004ad5 commit 5e94f38
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion requests/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def cert_verify(self, conn, url, verify, cert):
: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

Expand Down
2 changes: 1 addition & 1 deletion requests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def get_adapter(self, url):
"""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 :-/
Expand Down
21 changes: 21 additions & 0 deletions test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@ def test_params_are_added_before_fragment(self):
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()
Expand Down

0 comments on commit 5e94f38

Please sign in to comment.