Skip to content

Commit d61785b

Browse files
Ignore expires and max_age arguments if passed to Response.delete_cookie (Fixes #323)
1 parent 680cbef commit d61785b

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/microdot/microdot.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,13 @@ def delete_cookie(self, cookie, **kwargs):
632632
"""Delete a cookie.
633633
634634
:param cookie: The cookie's name.
635-
:param kwargs: Any cookie opens and flags supported by
636-
``set_cookie()`` except ``expires`` and ``max_age``.
635+
:param kwargs: Any cookie options and flags supported by
636+
:meth:`set_cookie() <microdot.Response.set_cookie>`.
637+
Values given for ``expires`` and ``max_age`` are
638+
ignored.
637639
"""
640+
kwargs.pop('expires', None)
641+
kwargs.pop('max_age', None)
638642
self.set_cookie(cookie, '', expires='Thu, 01 Jan 1970 00:00:01 GMT',
639643
max_age=0, **kwargs)
640644

src/microdot/session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ def delete(self):
2525
class Session:
2626
"""
2727
:param app: The application instance.
28-
:param key: The secret key, as a string or bytes object.
28+
:param secret_key: The secret key, as a string or bytes object.
29+
:param cookie_options: A dictionary with cookie options to pass as
30+
arguments to :meth:`Response.set_cookie()
31+
<microdot.Response.set_cookie>`.
2932
"""
3033
secret_key = None
3134

tests/test_microdot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ def index(req):
204204
res.set_cookie('four', '4')
205205
res.delete_cookie('two', path='/')
206206
res.delete_cookie('one', path='/bad')
207+
res.delete_cookie('five', max_age=123, expires='foo')
207208
return res
208209

209-
client = TestClient(app, cookies={'one': '1', 'two': '2'})
210+
client = TestClient(app, cookies={'one': '1', 'two': '2', 'five': '5'})
210211
res = self._run(client.get('/', headers={'Cookie': 'three=3'}))
211212
self.assertEqual(res.status_code, 200)
212213
self.assertEqual(res.headers['Content-Type'],

0 commit comments

Comments
 (0)