Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #850 from SecurityForUs/fix_proxies_2.7-3

Resolve issue in #849
  • Loading branch information...
commit 106bae645763fe36f5f3df4bc3203b9f8d5f4976 2 parents 64fd0ba + 65c19bc
@kennethreitz authored
Showing with 31 additions and 0 deletions.
  1. +4 −0 requests/models.py
  2. +27 −0 tests/test_proxies.py
View
4 requests/models.py
@@ -111,6 +111,10 @@ def __init__(self,
# Dictionary mapping protocol to the URL of the proxy (e.g. {'http': 'foo.bar:3128'})
self.proxies = dict(proxies or [])
+ for proxy_type,uri_ref in list(self.proxies.items()):
+ if not uri_ref:
+ del self.proxies[proxy_type]
+
# If no proxies are given, allow configuration by environment variables
# HTTP_PROXY and HTTPS_PROXY.
if not self.proxies and self.config.get('trust_env'):
View
27 tests/test_proxies.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import sys, os, unittest
+
+# Path hack.
+sys.path.insert(0, os.path.abspath('..'))
+import requests
+
+
+class HTTPSProxyTest(unittest.TestCase):
+ """Smoke test for https functionality."""
+
+ smoke_url = "https://github.com"
+
+ def test_empty_https_proxy(self):
+ proxy = {"https" : "" }
+ result = requests.get(self.smoke_url, verify=False, proxies = proxy)
+ self.assertEqual(result.status_code, 200)
+
+ def test_empty_http_proxy(self):
+ proxy = {"http" : "" }
+ result = requests.get(self.smoke_url, proxies = proxy)
+ self.assertEqual(result.status_code, 200)
+
+if __name__ == '__main__':
+ unittest.main()
Please sign in to comment.
Something went wrong with that request. Please try again.