You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
Remove expired cookies (#929)
* added a test for expiring cookies * updated tests * set up util for extracting expired cookies from response header * Revert "updated tests" This reverts commita4eb5c4498
. * Revert "Revert "updated tests"" This reverts commitd242e21bce
. * added more functionality to get-expired-cookies * add 'clear expired cookies' from session.json files * refactored get_expired_cookies * fixed formatting issues * ensured key exists in cookie_header dict * fixed linting errors * removed unused import * Added tests for get_expired_cookies util * Added additional test for get_expired_cookies * added remove_expired_cookies method directly to sessions class * extracted logic to clear cookies to sessions.py * refactored utils * added tests to check expired cookies being removed from session obj * added type annotations for methods * Refactored test_sessions * Seperated out expiry related tests into own class * Refactored get_expired_cookies in utils * Refactored remove cookie methods * fixed linting errors * fixed indentation and also pluralized test class name * removed inheritance from SessionTestbase class * Moved related test to TestExpiredCookies class Co-authored-by: kbanc <katherine.bancoft@gmail.com>
This commit is contained in:
@@ -5,11 +5,11 @@ Persistent, JSON-serialized sessions.
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union
|
||||
from typing import Iterable, Optional, Union
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
from requests.auth import AuthBase
|
||||
from requests.cookies import RequestsCookieJar, create_cookie
|
||||
from requests.cookies import RequestsCookieJar, create_cookie, remove_cookie_by_name
|
||||
|
||||
from httpie.cli.dicts import RequestHeadersDict
|
||||
from httpie.config import BaseConfigDict, DEFAULT_CONFIG_DIR
|
||||
@@ -144,3 +144,8 @@ class Session(BaseConfigDict):
|
||||
def auth(self, auth: dict):
|
||||
assert {'type', 'raw_auth'} == auth.keys()
|
||||
self['auth'] = auth
|
||||
|
||||
def remove_cookies(self, names: Iterable[str]):
|
||||
for name in names:
|
||||
if name in self['cookies']:
|
||||
del self['cookies'][name]
|
||||
|
Reference in New Issue
Block a user