Skip to content

Commit 0bfcee4

Browse files
default port for the socks5h scheme (#972)
* default port for the socks5h scheme * Update test_models.py * Update test_models.py * Update test_models.py
1 parent 4e0a17c commit 0bfcee4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

httpcore/_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ def origin(self) -> Origin:
284284
b"ws": 80,
285285
b"wss": 443,
286286
b"socks5": 1080,
287+
b"socks5h": 1080,
287288
}[self.scheme]
288289
return Origin(
289290
scheme=self.scheme, host=self.host, port=self.port or default_port

tests/test_models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ def test_url_cannot_include_unicode_strings():
4141
httpcore.URL(scheme=b"https", host=b"www.example.com", target="/☺".encode("utf-8"))
4242

4343

44+
def test_url_origin_socks5():
45+
url = httpcore.URL("socks5://127.0.0.1")
46+
origin = url.origin
47+
assert origin == httpcore.Origin(scheme=b"socks5", host=b"127.0.0.1", port=1080)
48+
assert str(origin) == "socks5://127.0.0.1:1080"
49+
50+
url = httpcore.URL("socks5h://127.0.0.1")
51+
origin = url.origin
52+
assert origin == httpcore.Origin(scheme=b"socks5h", host=b"127.0.0.1", port=1080)
53+
assert str(origin) == "socks5h://127.0.0.1:1080"
54+
55+
4456
# Request
4557

4658

0 commit comments

Comments
 (0)