From 44beaa1c8fd2e2882dc6565c026c2fc1385c8d40 Mon Sep 17 00:00:00 2001 From: Stephen Brown II Date: Sun, 28 Jul 2019 21:43:06 -0500 Subject: [PATCH] Make Origin use scheme, not is_ssl (#168) --- docs/api.md | 1 + httpx/dispatch/connection_pool.py | 6 ++---- httpx/models.py | 5 +++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api.md b/docs/api.md index dbc3d521..f5286dd0 100644 --- a/docs/api.md +++ b/docs/api.md @@ -110,6 +110,7 @@ True ``` * `def __init__(url)` +* `.scheme` - **str** * `.is_ssl` - **bool** * `.host` - **str** * `.port` - **int** diff --git a/httpx/dispatch/connection_pool.py b/httpx/dispatch/connection_pool.py index b6c0457c..374c76a3 100644 --- a/httpx/dispatch/connection_pool.py +++ b/httpx/dispatch/connection_pool.py @@ -26,10 +26,8 @@ class ConnectionStore: """ def __init__(self) -> None: - self.all = {} # type: typing.Dict[HTTPConnection, float] - self.by_origin = ( - {} - ) # type: typing.Dict[Origin, typing.Dict[HTTPConnection, float]] + self.all: typing.Dict[HTTPConnection, float] = {} + self.by_origin: typing.Dict[Origin, typing.Dict[HTTPConnection, float]] = {} def pop_by_origin( self, origin: Origin, http2_only: bool = False diff --git a/httpx/models.py b/httpx/models.py index bea47faf..4cb44a42 100644 --- a/httpx/models.py +++ b/httpx/models.py @@ -233,6 +233,7 @@ class Origin: def __init__(self, url: URLTypes) -> None: if not isinstance(url, URL): url = URL(url) + self.scheme = url.scheme self.is_ssl = url.is_ssl self.host = url.host self.port = url.port @@ -240,13 +241,13 @@ class Origin: def __eq__(self, other: typing.Any) -> bool: return ( isinstance(other, self.__class__) - and self.is_ssl == other.is_ssl + and self.scheme == other.scheme and self.host == other.host and self.port == other.port ) def __hash__(self) -> int: - return hash((self.is_ssl, self.host, self.port)) + return hash((self.scheme, self.host, self.port)) class QueryParams(typing.Mapping[str, str]): -- 2.47.3