mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
parent
34e64fe5d8
commit
f0f901a15d
@ -272,19 +272,15 @@ class ProjectHandler:
|
|||||||
response.content_length = None
|
response.content_length = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield from wait_run_in_executor(ProjectHandler._read_file, path, request, response)
|
with open(path, "rb") as f:
|
||||||
|
response.start(request)
|
||||||
|
while True:
|
||||||
|
data = f.read(4096)
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
yield from response.write(data)
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
raise aiohttp.web.HTTPNotFound()
|
raise aiohttp.web.HTTPNotFound()
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
raise aiohttp.web.HTTPForbidden
|
raise aiohttp.web.HTTPForbidden
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _read_file(path, request, response):
|
|
||||||
|
|
||||||
with open(path, "rb") as f:
|
|
||||||
response.start(request)
|
|
||||||
while True:
|
|
||||||
data = f.read(4096)
|
|
||||||
if not data:
|
|
||||||
break
|
|
||||||
response.write(data)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user