From b8561cda5e2bf9cb0129c2863ff52754e837ad85 Mon Sep 17 00:00:00 2001 From: Mher Movsisyan Date: Sun, 27 May 2012 22:21:26 +0500 Subject: [PATCH 1/2] no_proxy support --- requests/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requests/models.py b/requests/models.py index 79a3bc36..94e6e036 100644 --- a/requests/models.py +++ b/requests/models.py @@ -9,6 +9,7 @@ This module contains the primary objects that power Requests. import json import os +import string from datetime import datetime from .hooks import dispatch_hook, HOOKS @@ -521,9 +522,10 @@ class Request(object): self.headers['Content-Type'] = content_type _p = urlparse(url) + no_proxy = filter(string.strip, self.proxies.get('no', '').split(',')) proxy = self.proxies.get(_p.scheme) - if proxy: + if proxy and not any(map(_p.netloc.endswith, no_proxy)): conn = poolmanager.proxy_from_url(proxy) _proxy = urlparse(proxy) if '@' in _proxy.netloc: From cb8f9756e3cf57a12ea5619609460f29f930fd3d Mon Sep 17 00:00:00 2001 From: Mher Movsisyan Date: Mon, 28 May 2012 14:11:59 +0500 Subject: [PATCH 2/2] Fixes python3 compatibility issue --- requests/models.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requests/models.py b/requests/models.py index 94e6e036..92cb722f 100644 --- a/requests/models.py +++ b/requests/models.py @@ -9,7 +9,6 @@ This module contains the primary objects that power Requests. import json import os -import string from datetime import datetime from .hooks import dispatch_hook, HOOKS @@ -522,7 +521,7 @@ class Request(object): self.headers['Content-Type'] = content_type _p = urlparse(url) - no_proxy = filter(string.strip, self.proxies.get('no', '').split(',')) + no_proxy = filter(lambda x:x.strip(), self.proxies.get('no', '').split(',')) proxy = self.proxies.get(_p.scheme) if proxy and not any(map(_p.netloc.endswith, no_proxy)):