MCPcopy
hub / github.com/urllib3/urllib3 / urlopen

Method urlopen

src/urllib3/connectionpool.py:592–973  ·  view source on GitHub ↗

Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you'll need to specify all the raw details. .. note:: More commonly, it's appropriate to use a convenience method such as :meth:

(  # type: ignore[override]
        self,
        method: str,
        url: str,
        body: _TYPE_BODY | None = None,
        headers: typing.Mapping[str, str] | None = None,
        retries: Retry | bool | int | None = None,
        redirect: bool = True,
        assert_same_host: bool = True,
        timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT,
        pool_timeout: int | None = None,
        release_conn: bool | None = None,
        chunked: bool = False,
        body_pos: _TYPE_BODY_POSITION | None = None,
        preload_content: bool = True,
        decode_content: bool = True,
        **response_kw: typing.Any,
    )

Source from the content-addressed store, hash-verified

590 return (scheme, host, port) == (self.scheme, self.host, self.port)
591
592 def urlopen( # type: ignore[override]
593 self,
594 method: str,
595 url: str,
596 body: _TYPE_BODY | None = None,
597 headers: typing.Mapping[str, str] | None = None,
598 retries: Retry | bool | int | None = None,
599 redirect: bool = True,
600 assert_same_host: bool = True,
601 timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT,
602 pool_timeout: int | None = None,
603 release_conn: bool | None = None,
604 chunked: bool = False,
605 body_pos: _TYPE_BODY_POSITION | None = None,
606 preload_content: bool = True,
607 decode_content: bool = True,
608 **response_kw: typing.Any,
609 ) -> BaseHTTPResponse:
610 """
611 Get a connection from the pool and perform an HTTP request. This is the
612 lowest level call for making a request, so you'll need to specify all
613 the raw details.
614
615 .. note::
616
617 More commonly, it's appropriate to use a convenience method
618 such as :meth:`request`.
619
620 .. note::
621
622 `release_conn` will only behave as expected if
623 `preload_content=False` because we want to make
624 `preload_content=False` the default behaviour someday soon without
625 breaking backwards compatibility.
626
627 :param method:
628 HTTP request method (such as GET, POST, PUT, etc.)
629
630 :param url:
631 The URL to perform the request on.
632
633 :param body:
634 Data to send in the request body, either :class:`str`, :class:`bytes`,
635 an iterable of :class:`str`/:class:`bytes`, or a file-like object.
636
637 :param headers:
638 Dictionary of custom headers to send, such as User-Agent,
639 If-None-Match, etc. If None, pool headers are used. If provided,
640 these headers completely replace any pool-specific headers.
641
642 :param retries:
643 Configure the number of retries to allow before raising a
644 :class:`~urllib3.exceptions.MaxRetryError` exception.
645
646 If ``None`` (default) will retry 3 times, see ``Retry.DEFAULT``. Pass a
647 :class:`~urllib3.util.retry.Retry` object for fine-grained control
648 over different types of retries.
649 Pass an integer number to retry connection errors that many times,

Callers 1

pyodide_testFunction · 0.95

Calls 15

is_same_hostMethod · 0.95
_get_timeoutMethod · 0.95
_get_connMethod · 0.95
_prepare_proxyMethod · 0.95
_raise_timeoutMethod · 0.95
_make_requestMethod · 0.95
_put_connMethod · 0.95
to_strFunction · 0.85
_encode_targetFunction · 0.85
parse_urlFunction · 0.85
HostChangedErrorClass · 0.85

Tested by 1

pyodide_testFunction · 0.76