Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions docs/source/guide/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ client = Client(proxies=[proxy])
```python
# SOCKS5
client = Client(
proxies=[Proxy.http("socks5://username:password@127.0.0.1:1080")]
proxies=[Proxy.all("socks5://username:password@127.0.0.1:1080")]
)


# SOCKS5h (DNS also resolved by the proxy)
client = Client(
proxies=[Proxy.http("socks5h://username:password@127.0.0.1:6152")]
proxies=[Proxy.all("socks5h://username:password@127.0.0.1:6152")]
)
```

Expand All @@ -100,8 +100,7 @@ from wreq import Proxy
async def main():
resp = await wreq.get(
"https://httpbin.io/anything",
proxies=[
Proxy.all(
proxy=Proxy.all(
url="http://127.0.0.1:6152",
custom_http_headers={
"user-agent": "wreq",
Expand All @@ -110,7 +109,6 @@ async def main():
"x-proxy": "wreq",
},
)
],
)
print(await resp.text())

Expand All @@ -133,24 +131,11 @@ from wreq import Proxy
async def main():
resp = await wreq.get(
"http://localhost/v1.41/containers/json",
proxies=[Proxy.unix("/var/run/docker.sock")],
proxy=Proxy.unix("/var/run/docker.sock"),
)
print(await resp.text())

asyncio.run(main())
```

Even though the URL says `http://localhost`, the request never touches the network. It goes directly through the socket file at the given path.

---

## Choosing the right constructor

Each constructor controls which requests are intercepted by the proxy:

| Constructor | Intercepts |
|---|---|
| `Proxy.all(url)` | All requests (HTTP + HTTPS) |
| `Proxy.http(url)` | HTTP requests only |
| `Proxy.https(url)` | HTTPS requests only |
| `Proxy.unix(path)` | Requests via a Unix socket |
2 changes: 1 addition & 1 deletion docs/source/guide/websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def recv_message(ws):

async def main():
# Connect to HTTP/2 WebSocket server
client = wreq.Client(verify=False)
client = wreq.Client(tls_verify=False)
ws: WebSocket = await client.websocket(
"wss://127.0.0.1:3000/ws",
version=Version.HTTP_2
Expand Down
4 changes: 3 additions & 1 deletion tests/multipart_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ async def test_reuse_multipart_with_clonable_parts():
form = Multipart(
Part(name="a", value="1"),
Part(name="b", value=b"2"),
Part(name="c", value=Path("./README.md"), filename="README.md", mime="text/plain"),
Part(
name="c", value=Path("./README.md"), filename="README.md", mime="text/plain"
),
)

for _ in range(3):
Expand Down
Loading