Add support for modifying Content-Type

This commit is contained in:
blank X 2021-05-21 17:01:05 +07:00
parent 10a15f33c8
commit fcadd6383c
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 8 additions and 5 deletions

View File

@ -111,6 +111,13 @@ async def handler(request):
)
status = 206
length = end - offset + 1
headers = {
'Content-Range': f'bytes {offset}-{end}/{max_size}',
'Content-Length': str(length),
'Accept-Ranges': 'bytes'
}
if content_type := requests.headers.get('Content-Type'):
headers['Content-Type'] = content_type
async def download():
tmp_offset = offset
@ -131,11 +138,7 @@ async def handler(request):
return web.Response(status=status,
body=download(),
headers={
'Content-Range': f'bytes {offset}-{end}/{max_size}',
'Content-Length': str(length),
'Accept-Ranges': 'bytes'
}
headers=headers
)
app = web.Application()