http_server.Response: use right names for cookie keys

This commit is contained in:
Izalia Mae 2021-10-13 05:02:16 -04:00
parent d2b3fd6ca8
commit 38ab2b67e6

View file

@ -1,6 +1,6 @@
import json, sanic import json, sanic, traceback
from datetime import datetime from datetime import datetime, timedelta
from sanic.compat import Header from sanic.compat import Header
from sanic.cookies import CookieJar from sanic.cookies import CookieJar
from sanic.response import text as Raw from sanic.response import text as Raw
@ -11,37 +11,37 @@ from ..template import Color
class Response: class Response:
content_types = DotDict({ content_types = DotDict(
'text': 'text/plain', text = 'text/plain',
'html': 'text/html', html = 'text/html',
'css': 'text/css', css = 'text/css',
'javascript': 'application/javascript', javascript = 'application/javascript',
'json': 'application/json', json = 'application/json',
'activitypub': 'application/activity+json' activitypub = 'application/activity+json'
}) )
default_theme = DotDict({ default_theme = DotDict(
'primary': Color('#e7a'), primary = Color('#e7a'),
'secondary': Color('#a7e'), secondary = Color('#a7e'),
'background': Color('#191919'), background = Color('#191919'),
'positive': Color('#aea'), positive = Color('#aea'),
'negative': Color('#e99'), negative = Color('#e99'),
'white': Color('#eee'), white = Color('#eee'),
'black': Color('#111'), black = Color('#111'),
'speed': 250 speed = 250
}) )
cookie_keys = { cookie_keys = DotDict(
'expires': 'Expires', Expires = 'expires',
'path': 'Path', Path = 'path',
'comment': 'Comment', Comment = 'comment',
'domain': 'Domain', Domain = 'domain',
'max_age': 'Max-Age', MaxAge = 'max-age',
'secure': 'Secure', Secure = 'secure',
'httponly': 'HttpOnly', HttpOnly = 'httponly',
'version': 'Version', Version = 'version',
'samesite': 'SameSite' SameSite = 'samesite'
} )
def __init__(self, app, request, body=None, headers={}, cookies={}, status=200, content_type='text/html'): def __init__(self, app, request, body=None, headers={}, cookies={}, status=200, content_type='text/html'):
@ -142,10 +142,7 @@ class Response:
elif not isinstance(v, datetime): elif not isinstance(v, datetime):
raise TypeError('Expires must be a string or datetime') raise TypeError('Expires must be a string or datetime')
try: self.cookies[key][k] = v
self.cookies[key][k] = v
except KeyError as e:
izzylog.error('Invalid cookie key:', k)
def get_cookie(self, key): def get_cookie(self, key):