Extract the cookies from the response into a CookieJar. :param jar: http.cookiejar.CookieJar (not necessarily a RequestsCookieJar) :param request: our own requests.Request object :param response: urllib3.HTTPResponse object
(
jar: CookieJar, request: PreparedRequest, response: Any
)
| 133 | |
| 134 | |
| 135 | def extract_cookies_to_jar( |
| 136 | jar: CookieJar, request: PreparedRequest, response: Any |
| 137 | ) -> None: |
| 138 | """Extract the cookies from the response into a CookieJar. |
| 139 | |
| 140 | :param jar: http.cookiejar.CookieJar (not necessarily a RequestsCookieJar) |
| 141 | :param request: our own requests.Request object |
| 142 | :param response: urllib3.HTTPResponse object |
| 143 | """ |
| 144 | if not (hasattr(response, "_original_response") and response._original_response): |
| 145 | return |
| 146 | # the _original_response field is the wrapped httplib.HTTPResponse object, |
| 147 | req = MockRequest(request) |
| 148 | # pull out the HTTPMessage with the headers and put it in the mock: |
| 149 | res = MockResponse(response._original_response.msg) |
| 150 | jar.extract_cookies(res, req) # type: ignore[arg-type] |
| 151 | |
| 152 | |
| 153 | def get_cookie_header(jar: CookieJar, request: PreparedRequest) -> str | None: |
no test coverage detected