MCPcopy
hub / github.com/urllib3/urllib3 / connection_from_host

Method connection_from_host

src/urllib3/poolmanager.py:290–317  ·  view source on GitHub ↗

Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is provided, it is merged with the instance'

(
        self,
        host: str | None,
        port: int | None = None,
        scheme: str | None = "http",
        pool_kwargs: dict[str, typing.Any] | None = None,
    )

Source from the content-addressed store, hash-verified

288 self.pools.clear()
289
290 def connection_from_host(
291 self,
292 host: str | None,
293 port: int | None = None,
294 scheme: str | None = "http",
295 pool_kwargs: dict[str, typing.Any] | None = None,
296 ) -> HTTPConnectionPool:
297 """
298 Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme.
299
300 If ``port`` isn't given, it will be derived from the ``scheme`` using
301 ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is
302 provided, it is merged with the instance's ``connection_pool_kw``
303 variable and used to create the new connection pool, if one is
304 needed.
305 """
306
307 if not host:
308 raise LocationValueError("No host specified.")
309
310 request_context = self._merge_pool_kwargs(pool_kwargs)
311 request_context["scheme"] = scheme or "http"
312 if not port:
313 port = port_by_scheme.get(request_context["scheme"].lower(), 80)
314 request_context["port"] = port
315 request_context["host"] = host
316
317 return self.connection_from_context(request_context)
318
319 def connection_from_context(
320 self, request_context: dict[str, typing.Any]

Calls 4

_merge_pool_kwargsMethod · 0.95
LocationValueErrorClass · 0.85
getMethod · 0.80