mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 16:58:28 +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)
|
|
||||||
except FileNotFoundError:
|
|
||||||
raise aiohttp.web.HTTPNotFound()
|
|
||||||
except PermissionError:
|
|
||||||
raise aiohttp.web.HTTPForbidden
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _read_file(path, request, response):
|
|
||||||
|
|
||||||
with open(path, "rb") as f:
|
with open(path, "rb") as f:
|
||||||
response.start(request)
|
response.start(request)
|
||||||
while True:
|
while True:
|
||||||
data = f.read(4096)
|
data = f.read(4096)
|
||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
response.write(data)
|
yield from response.write(data)
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
raise aiohttp.web.HTTPNotFound()
|
||||||
|
except PermissionError:
|
||||||
|
raise aiohttp.web.HTTPForbidden
|
||||||
|
Loading…
Reference in New Issue
Block a user