]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Make Origin use scheme, not is_ssl (#168)
authorStephen Brown II <Stephen.Brown2@gmail.com>
Mon, 29 Jul 2019 02:43:06 +0000 (21:43 -0500)
committerSeth Michael Larson <sethmichaellarson@gmail.com>
Mon, 29 Jul 2019 02:43:06 +0000 (21:43 -0500)
docs/api.md
httpx/dispatch/connection_pool.py
httpx/models.py

index dbc3d5215f523cefafcf1171c1c680606f9a87e2..f5286dd0f3aa13e99d0b76d55523cba309711d2a 100644 (file)
@@ -110,6 +110,7 @@ True
 ```
 
 * `def __init__(url)`
+* `.scheme` - **str**
 * `.is_ssl` - **bool**
 * `.host` - **str**
 * `.port` - **int**
index b6c0457c5f1dc0f3a9f502eb4ee5cbd72a6078ec..374c76a384329d7e73e876c77abaafc6295b3e2c 100644 (file)
@@ -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
index bea47faf0dbda857666de8bf37d5364624ebfb74..4cb44a424330c5c5d557d6b946c30763580870d7 100644 (file)
@@ -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]):