@@ -74,13 +74,13 @@ client = Client(proxies=[proxy])
7474``` python
7575# SOCKS5
7676client = Client(
77- proxies = [Proxy.http (" socks5://username:password@127.0.0.1:1080" )]
77+ proxies = [Proxy.all (" socks5://username:password@127.0.0.1:1080" )]
7878)
7979
8080
8181# SOCKS5h (DNS also resolved by the proxy)
8282client = Client(
83- proxies = [Proxy.http (" socks5h://username:password@127.0.0.1:6152" )]
83+ proxies = [Proxy.all (" socks5h://username:password@127.0.0.1:6152" )]
8484)
8585```
8686
@@ -100,8 +100,7 @@ from wreq import Proxy
100100async def main ():
101101 resp = await wreq.get(
102102 " https://httpbin.io/anything" ,
103- proxies = [
104- Proxy.all(
103+ proxy = Proxy.all(
105104 url = " http://127.0.0.1:6152" ,
106105 custom_http_headers = {
107106 " user-agent" : " wreq" ,
@@ -110,7 +109,6 @@ async def main():
110109 " x-proxy" : " wreq" ,
111110 },
112111 )
113- ],
114112 )
115113 print (await resp.text())
116114
@@ -133,24 +131,11 @@ from wreq import Proxy
133131async def main ():
134132 resp = await wreq.get(
135133 " http://localhost/v1.41/containers/json" ,
136- proxies = [ Proxy.unix(" /var/run/docker.sock" )] ,
134+ proxy = Proxy.unix(" /var/run/docker.sock" ),
137135 )
138136 print (await resp.text())
139137
140138asyncio.run(main())
141139```
142140
143141Even though the URL says ` http://localhost ` , the request never touches the network. It goes directly through the socket file at the given path.
144-
145- ---
146-
147- ## Choosing the right constructor
148-
149- Each constructor controls which requests are intercepted by the proxy:
150-
151- | Constructor | Intercepts |
152- | ---| ---|
153- | ` Proxy.all(url) ` | All requests (HTTP + HTTPS) |
154- | ` Proxy.http(url) ` | HTTP requests only |
155- | ` Proxy.https(url) ` | HTTPS requests only |
156- | ` Proxy.unix(path) ` | Requests via a Unix socket |
0 commit comments