From e9cb3f9070b2a00fd2f1796e6d7dfafb7633522d Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Mon, 10 Aug 2015 11:44:37 +0200 Subject: [PATCH 1/2] Depends on pycurl as it seems now more recent than pycurl2. pycurl2 was a fork of pycurl as of 7.19.0 (Sep 9 2008). As of 2015-08-10, last commit on this repo is : 2013-08-09 (2 years). Now pycurl seems alive, current version being 7.19.5.1, with last commit being 1 month ago. As we introduce new constants absent from pycurl2, I think it's better to depend on the original pycurl version. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 522bd58..af10c58 100644 --- a/setup.py +++ b/setup.py @@ -90,7 +90,7 @@ def run_tests(): url="https://github.com/lispython/human_curl", packages=["human_curl"], install_requires=[ - 'pycurl2'], + 'pycurl'], tests_require=tests_require, license="BSD", # test_suite="nose.collector", From 3e2f113d9bb94f8ff0dfe5a3f0c2fa544e47c4f7 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Mon, 10 Aug 2015 11:48:57 +0200 Subject: [PATCH 2/2] Add more socks / http proxy modes. Adding the following proxy modes: http1.0, https1.0, socks4a, socks5-hostname as arguments for the proxy keyword. There is a compatibility layer for pycurl2 when the corresponding constants are absent from the pycurl library. --- human_curl/core.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/human_curl/core.py b/human_curl/core.py index 243e93f..8e07582 100644 --- a/human_curl/core.py +++ b/human_curl/core.py @@ -65,8 +65,24 @@ CURL_VERSION = "" logger.warn("Unknown pycURL / cURL version") +try: + PROXYTYPE_HTTP_1_0 = pycurl.PROXYTYPE_HTTP_1_0 +except AttributeError, e: + PROXYTYPE_HTTP_1_0 = 1 +try: + PROXYTYPE_SOCKS4A = pycurl.PROXYTYPE_SOCKS4A +except AttributeError, e: + PROXYTYPE_SOCKS4A = 6 +try: + PROXYTYPE_SOCKS5_HOSTNAME = pycurl.PROXYTYPE_SOCKS5_HOSTNAME +except AttributeError, e: + PROXYTYPE_SOCKS5_HOSTNAME = 7 PROXIES_TYPES_MAP = { + 'socks5-hostname': PROXYTYPE_SOCKS5_HOSTNAME, + 'socks4a': PROXYTYPE_SOCKS4A, + 'https1.0': PROXYTYPE_HTTP_1_0, + 'http1.0': PROXYTYPE_HTTP_1_0, 'socks5': pycurl.PROXYTYPE_SOCKS5, 'socks4': pycurl.PROXYTYPE_SOCKS4, 'http': pycurl.PROXYTYPE_HTTP, @@ -491,7 +507,7 @@ def build_opener(self, url, opener=None): opener.setopt(pycurl.PROXYPORT, proxy_addr[1]) opener.setopt(pycurl.PROXYTYPE, get_code_by_name(proxy_type)) - if proxy_type.upper() in ("CONNECT", "SSL", "HTTPS"): + if proxy_type.upper() in ("CONNECT", "SSL", "HTTPS", "HTTPS1.0"): # if CONNECT proxy, need use HTTPPROXYTINNEL opener.setopt(pycurl.HTTPPROXYTUNNEL, 1) if proxy_auth: