Skip to content

Commit c1401eb

Browse files
Version 0.14.5 (#482)
1 parent ce66166 commit c1401eb

File tree

4 files changed

+64
-10
lines changed

4 files changed

+64
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## 0.14.5 (January 18th, 2022)
8+
9+
- SOCKS proxy support. (#478)
10+
- Add proxy_auth argument to HTTPProxy (#481)
11+
- Improve error message on 'RemoteProtocolError' exception when server disconnects without sending a response (#479)
12+
713
## 0.14.4 (January 5th, 2022)
814

915
- Support HTTP/2 on HTTPS tunnelling proxies. (#468)

docs/index.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,31 @@ Some things HTTP Core does do:
1818

1919
* Sending HTTP requests.
2020
* Thread-safe / task-safe connection pooling.
21-
* HTTP(S) proxy support.
21+
* HTTP(S) proxy & SOCKS proxy support.
2222
* Supports HTTP/1.1 and HTTP/2.
2323
* Provides both sync and async interfaces.
2424
* Async backend support for `asyncio` and `trio`.
2525

2626
## Installation
2727

28-
For HTTP/1.1 only support, install with...
28+
For HTTP/1.1 only support, install with:
2929

3030
```shell
3131
$ pip install httpcore
3232
```
3333

34-
For HTTP/1.1 and HTTP/2 support, install with...
34+
For HTTP/1.1 and HTTP/2 support, install with:
3535

3636
```shell
3737
$ pip install httpcore[http2]
3838
```
3939

40+
For SOCKS proxy support, install with:
41+
42+
```shell
43+
$ pip install httpcore[socks]
44+
```
45+
4046
## Example
4147

4248
Let's check we're able to send HTTP requests:

docs/proxies.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Proxies
22

3-
The `httpcore` package currently provides support for HTTP proxies, using either "HTTP Forwarding" and "HTTP Tunnelling". Forwarding is a proxy mechanism for sending requests to `http` URLs via an intermediate proxy. Tunnelling is a proxy mechanism for sending requests to `https` URLs via an intermediate proxy.
3+
The `httpcore` package provides support for HTTP proxies, using either "HTTP Forwarding" or "HTTP Tunnelling". Forwarding is a proxy mechanism for sending requests to `http` URLs via an intermediate proxy. Tunnelling is a proxy mechanism for sending requests to `https` URLs via an intermediate proxy.
44

55
Sending requests via a proxy is very similar to sending requests using a standard connection pool:
66

@@ -25,22 +25,64 @@ Requests will automatically use either forwarding or tunnelling, depending on if
2525

2626
## Authentication
2727

28-
Proxy headers can be included in the initial configuration:
28+
Proxy authentication can be included in the initial configuration:
29+
30+
```python
31+
import httpcore
32+
33+
# A `Proxy-Authorization` header will be included on the initial proxy connection.
34+
proxy = httpcore.HTTPProxy(
35+
proxy_url="http://127.0.0.1:8080/",
36+
proxy_auth=("<username", "password")
37+
)
38+
```
39+
40+
Custom headers can also be included:
2941

3042
```python
3143
import httpcore
3244
import base64
3345

34-
auth = base64.b64encode(b"Basic <username>:<password>")
46+
# Construct and include a `Proxy-Authorization` header.
47+
auth = base64.b64encode(b"<username>:<password>")
3548
proxy = httpcore.HTTPProxy(
3649
proxy_url="http://127.0.0.1:8080/",
37-
proxy_headers={"Proxy-Authorization": auth}
50+
proxy_headers={"Proxy-Authorization": b"Basic " + auth}
3851
)
3952
```
4053

41-
## HTTP Versions
54+
## Proxy SSL and HTTP Versions
55+
56+
Proxy support currently only allows for HTTP/1.1 connections to the proxy,
57+
and does not currently support SSL proxy connections, which require HTTPS-in-HTTPS,
58+
59+
## SOCKS proxy support
60+
61+
The `httpcore` package also supports proxies using the SOCKS protocol.
62+
63+
Make sure to install the optional dependancy using `pip install httpcore[socks]`.
64+
65+
The `SOCKSProxy` class should be using instead of a standard connection pool:
4266

43-
Proxy support currently only allows for HTTP/1.1 connections to the proxy.
67+
```python
68+
import httpcore
69+
70+
# Note that the SOCKS port is 1080.
71+
proxy = httpcore.SOCKSProxy(proxy_url="socks://127.0.0.1:1080/")
72+
r = proxy.request("GET", "https://www.example.com/")
73+
```
74+
75+
Authentication via SOCKS is also supported:
76+
77+
```python
78+
import httpcore
79+
80+
proxy = httpcore.SOCKSProxy(
81+
proxy_url="socks://127.0.0.1:8080/",
82+
proxy_auth=("<username", "password")
83+
)
84+
r = proxy.request("GET", "https://www.example.com/")
85+
```
4486

4587
---
4688

httpcore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"WriteError",
8383
]
8484

85-
__version__ = "0.14.4"
85+
__version__ = "0.14.5"
8686

8787

8888
__locals = locals()

0 commit comments

Comments
 (0)