config.py
This file
Path
httpcore/config.py
117 lines · 3.2 KiB · Python
Last changed by
Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
History of this fileTake it
StuffTom Christiebefore adoption30530d4
lines 1–2why, one step back1import typing2Merge pull request #1 from encode/add-connectionsTom Christiebefore adoption7626fe7
line 3why, one step back3import certifiStuffTom Christiebefore adoption30530d4
line 4why, one step back4Merge pull request #1 from encode/add-connectionsTom Christiebefore adoption7626fe7
line 5why, one step back5StuffTom Christiebefore adoption30530d4
lines 6–10why, one step back6class SSLConfig:7 """8 SSL Configuration.9 """10Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 11–16why, one step back11 def __init__(12 self,13 *,14 cert: typing.Union[None, str, typing.Tuple[str, str]] = None,15 verify: typing.Union[str, bool] = True,16 ):StuffTom Christiebefore adoption30530d4
lines 17–19why, one step back17 self.cert = cert18 self.verify = verify19Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 20–25why, one step back20 def __eq__(self, other: typing.Any) -> bool:21 return (22 isinstance(other, self.__class__)23 and self.cert == other.cert24 and self.verify == other.verify25 )StuffTom Christiebefore adoption30530d4
line 26why, one step back26Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 27–35why, one step back27 def __hash__(self) -> int:28 as_tuple = (self.cert, self.verify)29 return hash(as_tuple)3031 def __repr__(self) -> str:32 class_name = self.__class__.__name__33 return f"{class_name}(cert={self.cert}, verify={self.verify})"3435StuffTom Christiebefore adoption30530d4
lines 36–46why, one step back36class TimeoutConfig:37 """38 Timeout values.39 """4041 def __init__(42 self,43 timeout: float = None,44 *,45 connect_timeout: float = None,46 read_timeout: float = None,Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
line 47why, one step back47 pool_timeout: float = None,StuffTom Christiebefore adoption30530d4
lines 48–57why, one step back48 ):49 if timeout is not None:50 # Specified as a single timeout value51 assert connect_timeout is None52 assert read_timeout is None53 assert pool_timeout is None54 connect_timeout = timeout55 read_timeout = timeout56 pool_timeout = timeout57Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
line 58why, one step back58 self.timeout = timeoutStuffTom Christiebefore adoption30530d4
lines 59–62why, one step back59 self.connect_timeout = connect_timeout60 self.read_timeout = read_timeout61 self.pool_timeout = pool_timeout62Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 63–69why, one step back63 def __eq__(self, other: typing.Any) -> bool:64 return (65 isinstance(other, self.__class__)66 and self.connect_timeout == other.connect_timeout67 and self.read_timeout == other.read_timeout68 and self.pool_timeout == other.pool_timeout69 )StuffTom Christiebefore adoption30530d4
line 70why, one step back70Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 71–81why, one step back71 def __hash__(self) -> int:72 as_tuple = (self.connect_timeout, self.read_timeout, self.pool_timeout)73 return hash(as_tuple)7475 def __repr__(self) -> str:76 class_name = self.__class__.__name__77 if self.timeout is not None:78 return f"{class_name}(timeout={self.timeout})"79 return f"{class_name}(connect_timeout={self.connect_timeout}, read_timeout={self.read_timeout}, pool_timeout={self.pool_timeout})"8081StuffTom Christiebefore adoption30530d4
lines 82–86why, one step back82class PoolLimits:83 """84 Limits on the number of connections in a connection pool.85 """86Merge pull request #4 from encode/connection-poolingTom Christiebefore adoption68c468a
lines 87–90why, one step back87 def __init__(88 self,89 *,90 soft_limit: typing.Optional[int] = None,Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
line 91why, one step back91 hard_limit: typing.Optional[int] = None,Merge pull request #4 from encode/connection-poolingTom Christiebefore adoption68c468a
lines 92–93why, one step back92 ):93 self.soft_limit = soft_limitStuffTom Christiebefore adoption30530d4
line 94why, one step back94 self.hard_limit = hard_limitMerge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 95–111why, one step back9596 def __eq__(self, other: typing.Any) -> bool:97 return (98 isinstance(other, self.__class__)99 and self.soft_limit == other.soft_limit100 and self.hard_limit == other.hard_limit101 )102103 def __hash__(self) -> int:104 as_tuple = (self.soft_limit, self.hard_limit)105 return hash(as_tuple)106107 def __repr__(self) -> str:108 class_name = self.__class__.__name__109 return (110 f"{class_name}(soft_limit={self.soft_limit}, hard_limit={self.hard_limit})"111 )StuffTom Christiebefore adoption30530d4
lines 112–115why, one step back112113114DEFAULT_SSL_CONFIG = SSLConfig(cert=None, verify=True)115DEFAULT_TIMEOUT_CONFIG = TimeoutConfig(timeout=5.0)Merge pull request #4 from encode/connection-poolingTom Christiebefore adoption68c468a
line 116why, one step back116DEFAULT_POOL_LIMITS = PoolLimits(soft_limit=10, hard_limit=100)Merge pull request #1 from encode/add-connectionsTom Christiebefore adoption7626fe7
line 117why, one step back117DEFAULT_CA_BUNDLE_PATH = certifi.where()