DNS Resolver¶
- class urllib3.contrib.resolver.BaseResolver(server, port=None, *patterns, **kwargs)¶
Bases:
object- abstract close()¶
Terminate the given resolver instance. This should render it unusable. Further inquiries should raise an exception.
- Return type:
None
- create_connection(address, timeout=_TYPE_DEFAULT.token, source_address=None, socket_options=None, socket_kind=SocketKind.SOCK_STREAM, *, quic_upgrade_via_dns_rr=False, timing_hook=None, default_socket_family=AddressFamily.AF_UNSPEC)¶
Connect to address and return the socket object.
Convenience function. Connect to address (a 2-tuple
(host, port)) and return the socket object. Passing the optional timeout parameter will set the timeout on the socket instance before attempting to connect. If no timeout is supplied, the global default timeout setting returned bysocket.getdefaulttimeout()is used. If source_address is set it must be a tuple of (host, port) for the socket to bind as a source address before making the connection. An host of ‘’ or port 0 tells the OS to use the default.- Parameters:
- Return type:
- abstract getaddrinfo(host, port, family, type, proto=0, flags=0, *, quic_upgrade_via_dns_rr=False)¶
This method align itself on the standard library socket.getaddrinfo(). It must be implemented as-is on your Resolver.
- protocol: ClassVar[ProtocolResolver]¶
- recycle()¶
- Return type:
- class urllib3.contrib.resolver.ManyResolver(*resolvers)¶
Bases:
BaseResolverSpecial resolver that use many child resolver. Priorities are based on given order (list of BaseResolver).
- Parameters:
resolvers (BaseResolver)
- close()¶
Terminate the given resolver instance. This should render it unusable. Further inquiries should raise an exception.
- Return type:
None
- getaddrinfo(host, port, family, type, proto=0, flags=0, *, quic_upgrade_via_dns_rr=False)¶
This method align itself on the standard library socket.getaddrinfo(). It must be implemented as-is on your Resolver.
- recycle()¶
- Return type:
- class urllib3.contrib.resolver.ProtocolResolver(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
-
At urllib3.future we aim to propose a wide range of DNS-protocols. The most used techniques are available.
- CUSTOM = 'custom'¶
Custom (e.g. your own implementation, use this when it does not suit any of the protocols specified)
- DOH = 'doh'¶
DNS over HTTPS
- DOQ = 'doq'¶
DNS over QUIC
- DOT = 'dot'¶
DNS over TLS
- DOU = 'dou'¶
DNS over UDP (insecure)
- MANUAL = 'in-memory'¶
Manual (e.g. hosts)
- NULL = 'null'¶
Void (e.g. purposely disable resolution)
- SYSTEM = 'system'¶
Ask the OS native DNS layer
- class urllib3.contrib.resolver.ResolverDescription(protocol, specifier=None, implementation=None, server=None, port=None, *host_patterns, **kwargs)¶
Bases:
objectDescribe how a BaseResolver must be instantiated.
- Parameters:
- new()¶
- Return type:
- class urllib3.contrib.resolver.ResolverFactory¶
Bases:
object- static has(protocol, specifier=None, implementation=None)¶
- Parameters:
protocol (ProtocolResolver)
specifier (str | None)
implementation (str | None)
- Return type:
- static new(protocol, specifier=None, implementation=None, **kwargs)¶
- Parameters:
protocol (ProtocolResolver)
specifier (str | None)
implementation (str | None)
kwargs (Any)
- Return type:
- class urllib3.contrib.resolver._async.AsyncBaseResolver(server, port=None, *patterns, **kwargs)¶
Bases:
BaseResolver- abstract async close()¶
Terminate the given resolver instance. This should render it unusable. Further inquiries should raise an exception.
- Return type:
None
- async create_connection(address, timeout=_TYPE_DEFAULT.token, source_address=None, socket_options=None, socket_kind=SocketKind.SOCK_STREAM, *, quic_upgrade_via_dns_rr=False, timing_hook=None, default_socket_family=AddressFamily.AF_UNSPEC)¶
Connect to address and return the socket object.
Convenience function. Connect to address (a 2-tuple
(host, port)) and return the socket object. Passing the optional timeout parameter will set the timeout on the socket instance before attempting to connect. If no timeout is supplied, the global default timeout setting returned bysocket.getdefaulttimeout()is used. If source_address is set it must be a tuple of (host, port) for the socket to bind as a source address before making the connection. An host of ‘’ or port 0 tells the OS to use the default.- Parameters:
- Return type:
- abstract async getaddrinfo(host, port, family, type, proto=0, flags=0, *, quic_upgrade_via_dns_rr=False)¶
This method align itself on the standard library socket.getaddrinfo(). It must be implemented as-is on your Resolver.
- recycle()¶
- Return type:
- class urllib3.contrib.resolver._async.AsyncManyResolver(*resolvers)¶
Bases:
AsyncBaseResolverSpecial resolver that use many child resolver. Priorities are based on given order (list of BaseResolver).
- Parameters:
resolvers (AsyncBaseResolver)
- async close()¶
Terminate the given resolver instance. This should render it unusable. Further inquiries should raise an exception.
- Return type:
None
- async getaddrinfo(host, port, family, type, proto=0, flags=0, *, quic_upgrade_via_dns_rr=False)¶
This method align itself on the standard library socket.getaddrinfo(). It must be implemented as-is on your Resolver.
- recycle()¶
- Return type:
- class urllib3.contrib.resolver._async.AsyncResolverDescription(protocol, specifier=None, implementation=None, server=None, port=None, *host_patterns, **kwargs)¶
Bases:
ResolverDescriptionDescribe how a BaseResolver must be instantiated.
- Parameters:
- new()¶
- Return type:
- class urllib3.contrib.resolver._async.AsyncResolverFactory¶
Bases:
object- static has(protocol, specifier=None, implementation=None)¶
- Parameters:
protocol (ProtocolResolver)
specifier (str | None)
implementation (str | None)
- Return type:
- static new(protocol, specifier=None, implementation=None, **kwargs)¶
- Parameters:
protocol (ProtocolResolver)
specifier (str | None)
implementation (str | None)
kwargs (Any)
- Return type: