python-proxy-headers 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (17) hide show
  1. {python_proxy_headers-0.2.0/python_proxy_headers.egg-info → python_proxy_headers-0.2.2}/PKG-INFO +2 -2
  2. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/pyproject.toml +3 -3
  3. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers/urllib3_proxy_manager.py +18 -0
  4. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2/python_proxy_headers.egg-info}/PKG-INFO +2 -2
  5. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/LICENSE +0 -0
  6. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/README.md +0 -0
  7. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers/__init__.py +0 -0
  8. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers/aiohttp_proxy.py +0 -0
  9. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers/autoscraper_proxy.py +0 -0
  10. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers/cloudscraper_proxy.py +0 -0
  11. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers/httpx_proxy.py +0 -0
  12. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers/pycurl_proxy.py +0 -0
  13. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers/requests_adapter.py +0 -0
  14. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers.egg-info/SOURCES.txt +0 -0
  15. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers.egg-info/dependency_links.txt +0 -0
  16. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/python_proxy_headers.egg-info/top_level.txt +0 -0
  17. {python_proxy_headers-0.2.0 → python_proxy_headers-0.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-proxy-headers
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Handle custom proxy headers for http & https requests in various python libraries
5
5
  Author-email: ProxyMesh <support@proxymesh.com>
6
6
  Project-URL: Homepage, https://github.com/proxymesh/python-proxy-headers
@@ -10,7 +10,7 @@ Project-URL: Documentation, https://python-proxy-headers.readthedocs.io/en/lates
10
10
  Project-URL: ProxyMesh, https://proxymesh.com
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Operating System :: OS Independent
13
- Classifier: License :: OSI Approved :: BSD License
13
+ Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Intended Audience :: Developers
15
15
  Classifier: Topic :: Internet :: WWW/HTTP
16
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python-proxy-headers"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  authors = [
9
9
  { name="ProxyMesh", email="support@proxymesh.com" },
10
10
  ]
@@ -14,7 +14,7 @@ requires-python = ">=3.8"
14
14
  classifiers = [
15
15
  "Programming Language :: Python :: 3",
16
16
  "Operating System :: OS Independent",
17
- "License :: OSI Approved :: BSD License",
17
+ "License :: OSI Approved :: MIT License",
18
18
  "Intended Audience :: Developers",
19
19
  "Topic :: Internet :: WWW/HTTP",
20
20
  "Topic :: Software Development :: Libraries :: Python Modules",
@@ -25,4 +25,4 @@ Homepage = "https://github.com/proxymesh/python-proxy-headers"
25
25
  Changelog = "https://github.com/proxymesh/python-proxy-headers/commits/main/"
26
26
  Issues = "https://github.com/proxymesh/python-proxy-headers/issues"
27
27
  Documentation = "https://python-proxy-headers.readthedocs.io/en/latest/"
28
- ProxyMesh = "https://proxymesh.com"
28
+ ProxyMesh = "https://proxymesh.com"
@@ -3,6 +3,8 @@ from http.client import _read_headers
3
3
  from urllib3.connection import HTTPSConnection
4
4
  from urllib3.connectionpool import HTTPConnectionPool, HTTPSConnectionPool
5
5
  from urllib3.poolmanager import ProxyManager
6
+ from urllib3.util.request import make_headers
7
+ from urllib3.util.url import parse_url
6
8
 
7
9
  if sys.version_info < (3, 12, 0):
8
10
  #####################################
@@ -128,6 +130,22 @@ class HTTPSProxyConnectionPool(HTTPSConnectionPool):
128
130
 
129
131
  class ProxyHeaderManager(ProxyManager):
130
132
  def __init__(self, *args, **kwargs):
133
+ # urllib3.ProxyManager does not add Proxy-Authorization from user:pass in the
134
+ # proxy URL; requests does via HTTPAdapter.proxy_headers(). Merge URL auth here
135
+ # so direct proxy_from_url() matches requests and authenticates CONNECT.
136
+ proxy_url = kwargs.get("proxy_url")
137
+ if proxy_url is None and args:
138
+ proxy_url = args[0]
139
+ proxy_headers = kwargs.get("proxy_headers")
140
+ merged = dict(proxy_headers or {})
141
+ if isinstance(proxy_url, str):
142
+ parsed = parse_url(proxy_url)
143
+ if parsed.auth and not any(
144
+ k.lower() == "proxy-authorization" for k in merged
145
+ ):
146
+ merged.update(make_headers(proxy_basic_auth=parsed.auth))
147
+ if merged != dict(proxy_headers or {}):
148
+ kwargs["proxy_headers"] = merged
131
149
  super().__init__(*args, **kwargs)
132
150
  self.pool_classes_by_scheme = {"http": HTTPConnectionPool, "https": HTTPSProxyConnectionPool}
133
151
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-proxy-headers
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Handle custom proxy headers for http & https requests in various python libraries
5
5
  Author-email: ProxyMesh <support@proxymesh.com>
6
6
  Project-URL: Homepage, https://github.com/proxymesh/python-proxy-headers
@@ -10,7 +10,7 @@ Project-URL: Documentation, https://python-proxy-headers.readthedocs.io/en/lates
10
10
  Project-URL: ProxyMesh, https://proxymesh.com
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Operating System :: OS Independent
13
- Classifier: License :: OSI Approved :: BSD License
13
+ Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Intended Audience :: Developers
15
15
  Classifier: Topic :: Internet :: WWW/HTTP
16
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules