Add support for modifying Content-Type
This commit is contained in:
parent
10a15f33c8
commit
fcadd6383c
13
streamtg.py
13
streamtg.py
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue