mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Update aiohttp to 2.3.1 (#10139)
* Update aiohttp to 2.3.1 * set timeout 10sec * fix freeze with new middleware handling * Convert middleware auth * Convert mittleware ipban * convert middleware static * fix lint * Update ban.py * Update auth.py * fix lint * Fix tests
This commit is contained in:
committed by
Paulus Schoutsen
parent
39de557c4c
commit
a9a3e24bde
@@ -3,7 +3,7 @@ import asyncio
|
||||
import re
|
||||
|
||||
from aiohttp import hdrs
|
||||
from aiohttp.web import FileResponse
|
||||
from aiohttp.web import FileResponse, middleware
|
||||
from aiohttp.web_exceptions import HTTPNotFound
|
||||
from aiohttp.web_urldispatcher import StaticResource
|
||||
from yarl import unquote
|
||||
@@ -61,21 +61,17 @@ class CachingFileResponse(FileResponse):
|
||||
self._sendfile = sendfile
|
||||
|
||||
|
||||
@middleware
|
||||
@asyncio.coroutine
|
||||
def staticresource_middleware(app, handler):
|
||||
def staticresource_middleware(request, handler):
|
||||
"""Middleware to strip out fingerprint from fingerprinted assets."""
|
||||
@asyncio.coroutine
|
||||
def static_middleware_handler(request):
|
||||
"""Strip out fingerprints from resource names."""
|
||||
if not request.path.startswith('/static/'):
|
||||
return handler(request)
|
||||
|
||||
fingerprinted = _FINGERPRINT.match(request.match_info['filename'])
|
||||
|
||||
if fingerprinted:
|
||||
request.match_info['filename'] = \
|
||||
'{}.{}'.format(*fingerprinted.groups())
|
||||
|
||||
if not request.path.startswith('/static/'):
|
||||
return handler(request)
|
||||
|
||||
return static_middleware_handler
|
||||
fingerprinted = _FINGERPRINT.match(request.match_info['filename'])
|
||||
|
||||
if fingerprinted:
|
||||
request.match_info['filename'] = \
|
||||
'{}.{}'.format(*fingerprinted.groups())
|
||||
|
||||
return handler(request)
|
||||
|
||||
Reference in New Issue
Block a user