{"id":25640430,"url":"https://github.com/proxymesh/python-proxy-headers","last_synced_at":"2026-04-06T17:03:28.940Z","repository":{"id":278810182,"uuid":"936278361","full_name":"proxymesh/python-proxy-headers","owner":"proxymesh","description":"Handle custom proxy headers when making HTTPS requests in python","archived":false,"fork":false,"pushed_at":"2026-04-05T14:39:17.000Z","size":113,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-05T16:23:49.031Z","etag":null,"topics":["aiohttp","aiohttp-client","asyncio","autoscraper","cloudscraper","headers","http-proxy","httpx","httpx-client","proxy","proxy-headers","pycurl","python","python3","requests","requests-module","requests-python","scraping","scraping-python","urllib3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/python-proxy-headers/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/proxymesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-20T20:23:38.000Z","updated_at":"2026-04-05T14:37:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"b03dae05-668c-40a4-a2e0-d66db27dd9cd","html_url":"https://github.com/proxymesh/python-proxy-headers","commit_stats":null,"previous_names":["proxymesh/python-proxy-headers"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/proxymesh/python-proxy-headers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proxymesh%2Fpython-proxy-headers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proxymesh%2Fpython-proxy-headers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proxymesh%2Fpython-proxy-headers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proxymesh%2Fpython-proxy-headers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/proxymesh","download_url":"https://codeload.github.com/proxymesh/python-proxy-headers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proxymesh%2Fpython-proxy-headers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31481238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T14:34:32.243Z","status":"ssl_error","status_checked_at":"2026-04-06T14:34:31.723Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiohttp","aiohttp-client","asyncio","autoscraper","cloudscraper","headers","http-proxy","httpx","httpx-client","proxy","proxy-headers","pycurl","python","python3","requests","requests-module","requests-python","scraping","scraping-python","urllib3"],"created_at":"2025-02-23T04:24:59.140Z","updated_at":"2026-04-06T17:03:28.932Z","avatar_url":"https://github.com/proxymesh.png","language":"Python","readme":"# Python Proxy Headers\n\n[![Documentation Status](https://readthedocs.org/projects/python-proxy-headers/badge/?version=latest)](https://python-proxy-headers.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/python-proxy-headers.svg)](https://badge.fury.io/py/python-proxy-headers)\n\nExtensions for Python HTTP libraries to support **sending and receiving custom proxy headers** during HTTPS CONNECT tunneling.\n\n## The Problem\n\nWhen making HTTPS requests through a proxy, the connection is established via a CONNECT tunnel. During this process:\n\n1. **Sending headers to the proxy** - Most Python HTTP libraries don't provide an easy way to send custom headers (like `X-ProxyMesh-Country`) to the proxy server during the CONNECT handshake.\n\n2. **Receiving headers from the proxy** - The proxy's response headers from the CONNECT request are typically discarded, making it impossible to read custom headers (like `X-ProxyMesh-IP`) that the proxy sends back.\n\nThis library solves both problems for popular Python HTTP libraries.\n\n## Supported Libraries\n\n| Library | Module | Use Case |\n|---------|--------|----------|\n| [urllib3](https://python-proxy-headers.readthedocs.io/en/latest/urllib3.html) | `urllib3_proxy_manager` | Low-level HTTP client |\n| [requests](https://python-proxy-headers.readthedocs.io/en/latest/requests.html) | `requests_adapter` | Simple HTTP requests |\n| [aiohttp](https://python-proxy-headers.readthedocs.io/en/latest/aiohttp.html) | `aiohttp_proxy` | Async HTTP client |\n| [httpx](https://python-proxy-headers.readthedocs.io/en/latest/httpx.html) | `httpx_proxy` | Modern HTTP client |\n| [pycurl](https://python-proxy-headers.readthedocs.io/en/latest/pycurl.html) | `pycurl_proxy` | libcurl bindings |\n| [cloudscraper](https://python-proxy-headers.readthedocs.io/en/latest/cloudscraper.html) | `cloudscraper_proxy` | Cloudflare bypass |\n| [autoscraper](https://python-proxy-headers.readthedocs.io/en/latest/autoscraper.html) | `autoscraper_proxy` | Automatic web scraping |\n\n## Installation\n\n```bash\npip install python-proxy-headers\n```\n\nThen install the HTTP library you want to use (e.g., `pip install requests`).\n\n\u003e **Note:** This package has no dependencies by default - install only what you need.\n\n## Quick Start\n\n### requests\n\n```python\nfrom python_proxy_headers.requests_adapter import ProxySession\n\nwith ProxySession(proxy_headers={'X-ProxyMesh-Country': 'US'}) as session:\n    session.proxies = {'https': 'http://user:pass@proxy.example.com:8080'}\n    response = session.get('https://httpbin.org/ip')\n    \n    # Proxy headers are merged into response.headers\n    print(response.headers.get('X-ProxyMesh-IP'))\n```\n\n### httpx\n\n```python\nfrom python_proxy_headers.httpx_proxy import get\n\nresponse = get(\n    'https://httpbin.org/ip',\n    proxy='http://user:pass@proxy.example.com:8080'\n)\n\n# Proxy CONNECT response headers are merged into response.headers\nprint(response.headers.get('X-ProxyMesh-IP'))\n```\n\n### aiohttp\n\n```python\nimport asyncio\nfrom python_proxy_headers.aiohttp_proxy import ProxyClientSession\n\nasync def main():\n    async with ProxyClientSession() as session:\n        async with session.get(\n            'https://httpbin.org/ip',\n            proxy='http://user:pass@proxy.example.com:8080'\n        ) as response:\n            # Proxy headers merged into response.headers\n            print(response.headers.get('X-ProxyMesh-IP'))\n\nasyncio.run(main())\n```\n\n### pycurl (low-level)\n\n```python\nimport pycurl\nfrom python_proxy_headers.pycurl_proxy import set_proxy_headers, HeaderCapture\n\nc = pycurl.Curl()\nc.setopt(pycurl.URL, 'https://httpbin.org/ip')\nc.setopt(pycurl.PROXY, 'http://proxy.example.com:8080')\n\n# Add these two lines to any existing pycurl code\nset_proxy_headers(c, {'X-ProxyMesh-Country': 'US'})\ncapture = HeaderCapture(c)\n\nc.perform()\n\nprint(capture.proxy_headers)  # Headers from proxy CONNECT response\nc.close()\n```\n\n### cloudscraper\n\n```python\nfrom python_proxy_headers.cloudscraper_proxy import create_scraper\n\n# Drop-in replacement for cloudscraper.create_scraper()\nscraper = create_scraper(proxy_headers={'X-ProxyMesh-Country': 'US'})\nscraper.proxies = {'https': 'http://proxy.example.com:8080'}\n\nresponse = scraper.get('https://example.com')\n# All CloudScraper features (Cloudflare bypass) preserved\n```\n\n## Testing\n\nA test harness is included to verify proxy header functionality:\n\n```bash\n# Set your proxy\nexport PROXY_URL='http://user:pass@proxy.example.com:8080'\n\n# Test all modules\npython test_proxy_headers.py\n\n# Test specific modules\npython test_proxy_headers.py requests httpx\n\n# Verbose output (show header values)\npython test_proxy_headers.py -v\n```\n\n## Documentation\n\nFor detailed documentation, API reference, and more examples:\n\n- **Full Documentation:** [python-proxy-headers.readthedocs.io](https://python-proxy-headers.readthedocs.io/en/latest/)\n- **Example Code:** [proxy-examples for Python](https://github.com/proxymesh/proxy-examples/tree/main/python)\n\n## Related Projects\n\n- **[scrapy-proxy-headers](https://github.com/proxymesh/scrapy-proxy-headers)** - Proxy header support for Scrapy\n\n## About\n\nCreated by [ProxyMesh](https://proxymesh.com) to help our customers use custom headers to control proxy behavior. Works with any proxy that supports custom headers.\n\n## License\n\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproxymesh%2Fpython-proxy-headers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproxymesh%2Fpython-proxy-headers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproxymesh%2Fpython-proxy-headers/lists"}