Skip to content

Commit a79847c

Browse files
authored
Merge pull request #23 from proxymesh/chore/add-usage-skill
Add usage skill for AI agents
2 parents 2bce223 + 055d4ea commit a79847c

1 file changed

Lines changed: 125 additions & 0 deletions

File tree

  • .agents/skills/python-proxy-headers
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
name: python-proxy-headers
3+
description: >-
4+
Send and receive custom headers during HTTPS CONNECT tunneling in Python.
5+
Use when integrating proxy headers with requests, httpx, aiohttp, urllib3,
6+
pycurl, cloudscraper, or autoscraper.
7+
---
8+
9+
# python-proxy-headers
10+
11+
Send custom headers to proxies and receive proxy response headers during HTTPS CONNECT tunneling.
12+
13+
## Installation
14+
15+
```bash
16+
pip install python-proxy-headers
17+
```
18+
19+
Install your HTTP client as needed (requests, httpx, aiohttp, etc.).
20+
21+
## Quick Reference
22+
23+
| Library | Module | Main Class/Function |
24+
|---------|--------|---------------------|
25+
| requests | `python_proxy_headers.requests_adapter` | `ProxySession` |
26+
| httpx | `python_proxy_headers.httpx_proxy` | `get`, `post`, etc. |
27+
| aiohttp | `python_proxy_headers.aiohttp_proxy` | `ProxyClientSession` |
28+
| urllib3 | `python_proxy_headers.urllib3_proxy_manager` | `ProxyHeadersPoolManager` |
29+
| pycurl | `python_proxy_headers.pycurl_proxy` | `set_proxy_headers`, `HeaderCapture` |
30+
| cloudscraper | `python_proxy_headers.cloudscraper_proxy` | `create_scraper` |
31+
| autoscraper | `python_proxy_headers.autoscraper_proxy` | `ProxyAutoScraper` |
32+
33+
## Usage Patterns
34+
35+
### requests
36+
37+
```python
38+
from python_proxy_headers.requests_adapter import ProxySession
39+
40+
with ProxySession(proxy_headers={'X-ProxyMesh-Country': 'US'}) as session:
41+
session.proxies = {'https': 'http://user:pass@proxy.example.com:8080'}
42+
response = session.get('https://httpbin.org/ip')
43+
print(response.headers.get('X-ProxyMesh-IP'))
44+
```
45+
46+
### httpx
47+
48+
```python
49+
from python_proxy_headers.httpx_proxy import get
50+
51+
response = get(
52+
'https://httpbin.org/ip',
53+
proxy='http://user:pass@proxy.example.com:8080'
54+
)
55+
print(response.headers.get('X-ProxyMesh-IP'))
56+
```
57+
58+
### aiohttp
59+
60+
```python
61+
import asyncio
62+
from python_proxy_headers.aiohttp_proxy import ProxyClientSession
63+
64+
async def main():
65+
async with ProxyClientSession() as session:
66+
async with session.get(
67+
'https://httpbin.org/ip',
68+
proxy='http://user:pass@proxy.example.com:8080'
69+
) as response:
70+
print(response.headers.get('X-ProxyMesh-IP'))
71+
72+
asyncio.run(main())
73+
```
74+
75+
### pycurl
76+
77+
```python
78+
import pycurl
79+
from python_proxy_headers.pycurl_proxy import set_proxy_headers, HeaderCapture
80+
81+
c = pycurl.Curl()
82+
c.setopt(pycurl.URL, 'https://httpbin.org/ip')
83+
c.setopt(pycurl.PROXY, 'http://proxy.example.com:8080')
84+
85+
set_proxy_headers(c, {'X-ProxyMesh-Country': 'US'})
86+
capture = HeaderCapture(c)
87+
88+
c.perform()
89+
print(capture.proxy_headers)
90+
c.close()
91+
```
92+
93+
### cloudscraper
94+
95+
```python
96+
from python_proxy_headers.cloudscraper_proxy import create_scraper
97+
98+
scraper = create_scraper(proxy_headers={'X-ProxyMesh-Country': 'US'})
99+
scraper.proxies = {'https': 'http://proxy.example.com:8080'}
100+
response = scraper.get('https://example.com')
101+
```
102+
103+
## Proxy Headers
104+
105+
Custom headers sent during CONNECT are proxy-specific. Check your proxy provider's docs.
106+
107+
Example with [ProxyMesh](https://proxymesh.com):
108+
109+
| Header | Direction | Purpose |
110+
|--------|-----------|---------|
111+
| `X-ProxyMesh-Country` | Send | Route through specific country |
112+
| `X-ProxyMesh-IP` | Send/Receive | Request or receive sticky IP |
113+
114+
## Testing
115+
116+
```bash
117+
export PROXY_URL='http://user:pass@proxy.example.com:8080'
118+
python test_proxy_headers.py -v
119+
# or specific modules:
120+
python test_proxy_headers.py requests httpx
121+
```
122+
123+
## Documentation
124+
125+
Full docs at [python-proxy-headers.readthedocs.io](https://python-proxy-headers.readthedocs.io/).

0 commit comments

Comments
 (0)