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