Commit e0c5513e authored by Luna's avatar Luna 😻

api.bp.fetch: add HEAD handler for /i/ scope

parent c8bae7ff
Pipeline #42466196 passed with stage
in 1 minute and 1 second
......@@ -41,9 +41,7 @@ async def filecheck(request, filename):
return filepath, shortname
async def file_handler(request, filename):
"""Handles file serves."""
async def _get_file_ctx(request, filename):
app =
filepath, shortname = await filecheck(request, filename)
......@@ -52,9 +50,18 @@ async def file_handler(request, filename):
# taking a guess at it.
mimetype = await
# force utf-8 for text/plain
if mimetype == 'text/plain':
mimetype = 'text/plain; charset=utf-8'
return filepath, mimetype
async def file_handler(request, filename):
"""Handles file serves."""
filepath, mimetype = await _get_file_ctx(request, filename)
return await response.file_stream(
......@@ -63,6 +70,22 @@ async def file_handler(request, filename):
async def file_head_handler(request, filename):
"""Handle HEAD requests for /i/."""
_filepath, mimetype = await _get_file_ctx(request, filename)
# HEAD responses don't have bodies.
return response.raw(
'Content-Security-Policy': "sandbox; frame-src 'none'",
'Content-Type': mimetype
async def thumbnail_handler(request, filename):
"""Handles thumbnail serves."""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment