MCPcopy
hub / github.com/psf/requests / send

Method send

src/requests/adapters.py:634–748  ·  view source on GitHub ↗

Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send d

(
        self,
        request: PreparedRequest,
        stream: bool = False,
        timeout: _t.TimeoutType = None,
        verify: _t.VerifyType = True,
        cert: _t.CertType = None,
        proxies: dict[str, str] | None = None,
    )

Source from the content-addressed store, hash-verified

632 return headers
633
634 def send(
635 self,
636 request: PreparedRequest,
637 stream: bool = False,
638 timeout: _t.TimeoutType = None,
639 verify: _t.VerifyType = True,
640 cert: _t.CertType = None,
641 proxies: dict[str, str] | None = None,
642 ) -> Response:
643 """Sends PreparedRequest object. Returns Response object.
644
645 :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
646 :param stream: (optional) Whether to stream the request content.
647 :param timeout: (optional) How long to wait for the server to send
648 data before giving up, as a float, or a :ref:`(connect timeout,
649 read timeout) <timeouts>` tuple.
650 :type timeout: float or tuple or urllib3 Timeout object
651 :param verify: (optional) Either a boolean, in which case it controls whether
652 we verify the server&#x27;s TLS certificate, or a string, in which case it
653 must be a path to a CA bundle to use
654 :param cert: (optional) Any user-provided SSL certificate to be trusted.
655 :param proxies: (optional) The proxies dictionary to apply to the request.
656 :rtype: requests.Response
657 """
658
659 assert _is_prepared(request)
660
661 try:
662 conn = self.get_connection_with_tls_context(
663 request, verify, proxies=proxies, cert=cert
664 )
665 except LocationValueError as e:
666 raise InvalidURL(e, request=request)
667
668 self.cert_verify(conn, request.url, verify, cert)
669 url = self.request_url(request, proxies)
670 self.add_headers(
671 request,
672 stream=stream,
673 timeout=timeout,
674 verify=verify,
675 cert=cert,
676 proxies=proxies,
677 )
678
679 chunked = not (request.body is None or "Content-Length" in request.headers)
680
681 if isinstance(timeout, tuple):
682 try:
683 connect, read = timeout
684 resolved_timeout = TimeoutSauce(connect=connect, read=read)
685 except ValueError:
686 raise ValueError(
687 f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, "
688 f"or a single float to set both timeouts to the same value."
689 )
690 elif isinstance(timeout, TimeoutSauce):
691 resolved_timeout = timeout

Callers

nothing calls this directly

Calls 13

cert_verifyMethod · 0.95
request_urlMethod · 0.95
add_headersMethod · 0.95
build_responseMethod · 0.95
InvalidURLClass · 0.85
ConnectionErrorClass · 0.85
ConnectTimeoutClass · 0.85
RetryErrorClass · 0.85
ProxyErrorClass · 0.85
SSLErrorClass · 0.85
ReadTimeoutClass · 0.85

Tested by

no test coverage detected