MCPcopy Create free account
hub / github.com/psf/cachecontrol / send

Method send

cachecontrol/adapter.py:50–78  ·  view source on GitHub ↗

Send a request. Use the request information to see if it exists in the cache and cache the response if we need to and can.

(
        self,
        request: PreparedRequest,
        stream: bool = False,
        timeout: None | float | tuple[float, float] | tuple[float, None] = None,
        verify: bool | str = True,
        cert: (None | bytes | str | tuple[bytes | str, bytes | str]) = None,
        proxies: Mapping[str, str] | None = None,
        cacheable_methods: Collection[str] | None = None,
    )

Source from the content-addressed store, hash-verified

48 )
49
50 def send(
51 self,
52 request: PreparedRequest,
53 stream: bool = False,
54 timeout: None | float | tuple[float, float] | tuple[float, None] = None,
55 verify: bool | str = True,
56 cert: (None | bytes | str | tuple[bytes | str, bytes | str]) = None,
57 proxies: Mapping[str, str] | None = None,
58 cacheable_methods: Collection[str] | None = None,
59 ) -> Response:
60 """
61 Send a request. Use the request information to see if it
62 exists in the cache and cache the response if we need to and can.
63 """
64 cacheable = cacheable_methods or self.cacheable_methods
65 if request.method in cacheable:
66 try:
67 cached_response = self.controller.cached_request(request)
68 except zlib.error:
69 cached_response = None
70 if cached_response:
71 return self.build_response(request, cached_response, from_cache=True)
72
73 # check for etags and add headers if appropriate
74 request.headers.update(self.controller.conditional_headers(request))
75
76 resp = super().send(request, stream, timeout, verify, cert, proxies)
77
78 return resp
79
80 def build_response( # type: ignore[override]
81 self,

Callers

nothing calls this directly

Calls 3

build_responseMethod · 0.95
cached_requestMethod · 0.80
conditional_headersMethod · 0.80

Tested by

no test coverage detected