diff --git a/izzylib/http_frontend/base.haml b/izzylib/http_frontend/base.haml index 14f243e..7d9cc0a 100644 --- a/izzylib/http_frontend/base.haml +++ b/izzylib/http_frontend/base.haml @@ -2,7 +2,7 @@ %html %head %title << {{cfg.title}}: {{page}} - %link(rel='shortcut icon', type='image/png', href='/framework/static/icon64.png') + %link(rel='shortcut icon', type='image/png', href='{{cfg.tpl_favicon_path}}') %link(rel='stylesheet' type='text/css' href='/framework/style.css') %link(rel='manifest' href='/framework/manifest.json') %meta(charset='UTF-8') diff --git a/izzylib/http_server_async/__init__.py b/izzylib/http_server_async/__init__.py index dd92357..185e1ce 100644 --- a/izzylib/http_server_async/__init__.py +++ b/izzylib/http_server_async/__init__.py @@ -19,6 +19,7 @@ def create_app(appname, **kwargs): from .application import Application, Blueprint +from .middleware import MediaCacheControl from .misc import Cookies, Headers from .request import Request from .response import Response diff --git a/izzylib/http_server_async/config.py b/izzylib/http_server_async/config.py index 0da2965..01969f1 100644 --- a/izzylib/http_server_async/config.py +++ b/izzylib/http_server_async/config.py @@ -34,7 +34,8 @@ class Config(BaseConfig): tpl_globals = {}, tpl_context = None, tpl_autoescape = True, - tpl_default = True + tpl_default = True, + tpl_favicon_path = '/framework/static/icon64.png' ) self._startup = False diff --git a/izzylib/http_server_async/request.py b/izzylib/http_server_async/request.py index 2f6205e..3e5201f 100644 --- a/izzylib/http_server_async/request.py +++ b/izzylib/http_server_async/request.py @@ -7,6 +7,9 @@ from .misc import Cookies, Headers, CookieItem from ..dotdict import DotDict, MultiDotDict +try: from ..http_signatures import verify_headers +except ImportError: verify_headers = None + UtcTime = timezone.utc LocalTime = datetime.now(UtcTime).astimezone().tzinfo @@ -195,3 +198,16 @@ class Request: def new_response(self, *args, **kwargs): return self.app.cfg.response_class(*args, **kwargs) + + + async def verify_signature(self, actor): + if not verify_headers: + raise ImportError('Failed to import verify_headers from izzylib.http_signatures.') + + return verify_headers( + headers = {k: self.headers.getone(k) for k in request.headers.keys()}, + method = self.method, + path = self.path, + actor = actor, + body = await self.body + ) diff --git a/izzylib/http_server_async/view.py b/izzylib/http_server_async/view.py index 55b0c20..f3d3d0b 100644 --- a/izzylib/http_server_async/view.py +++ b/izzylib/http_server_async/view.py @@ -61,7 +61,7 @@ def Static(src): data = fd.read() if magic: - mime = magic.from_buffer(data[:2048], mime=True) or mimetypes.guess_type(path) + mime = mimetypes.guess_type(path)[0] or magic.from_buffer(data[:2048], mime=True) else: mime = mimetypes.guess_type(path)