[WIP] Implement cookie_filename support in check_features_manually#2807
[WIP] Implement cookie_filename support in check_features_manually#2807yyq1043-cloud wants to merge 1 commit into
Conversation
- Add _parse_cookie_file() to load cookies from Netscape-format cookies.txt - Add _inject_cookie_headers() to format cookies as the Cookie header - When cookie_filename is provided, create a temporary ClientSession with the loaded cookie jar and inject cookies into request headers - Fixes TODO: cookie_filename parameter is now actually used (250 lines)
|
Hi! I'd like to request review for this PR: Implement cookie_filename support in check_features_manually |
|
Thanks for picking this up! The idea β wiring the dead
|
|
Hi! I'd like to request review for this PR: [WIP] Implement cookie_filename support in check_features_manually |
Summary
Implement previously dead TODO in
submit.pyβ thecookie_filenameparameter ofcheck_features_manuallywas accepted but never used.When
--submitis invoked with--cookie-file <path>, site checks that go throughcheck_features_manually(e.g. withurlProbeprobes) now send the cookies from that file.Changes
_parse_cookie_file(): new@staticmethodthat callsimport_aiohttp_cookies()(already in activation.py) to load a Netscape/Mozilla cookies.txt into an aiohttpCookieJar. ReturnsNoneif the file is missing._inject_cookie_headers(): new instance method that formats cookies applicable to a URL as aCookie: name=value; name2=value2header, merged with any caller-supplied headers.check_features_manually(): whencookie_filenameis set, create a temporaryClientSessionwith the loaded cookie jar (SSL-off configuration mirrors the default session). Apply_inject_cookie_headers()to both HTTP requests made by the function.Testing
Verified by analysing the call path:
run()βinteractive_site_check()βcheck_features_manually(cookie_file=self.args.cookie_file, ...)check_features_manually()spans the existing-account check + non-existing-account check, both now include the cookie header when a file is provided.