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,
)
| 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, |
nothing calls this directly
no test coverage detected