mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 16:28:11 +00:00
parent
34e64fe5d8
commit
f0f901a15d
@ -272,19 +272,15 @@ class ProjectHandler:
|
||||
response.content_length = None
|
||||
|
||||
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:
|
||||
raise aiohttp.web.HTTPNotFound()
|
||||
except PermissionError:
|
||||
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