mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 14:31:13 +02:00
19 files changed
+72
-97
No files matched your search
@@ -16,8 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
import aiohttp.errors
|
||||
|
||||
import aiohttp
|
||||
from aiohttp.web import WebSocketResponse
|
||||
from gns3server.web.route import Route
|
||||
from gns3server.compute.notification_manager import NotificationManager
|
||||
@@ -30,7 +29,7 @@ def process_websocket(ws):
|
||||
"""
|
||||
try:
|
||||
yield from ws.receive()
|
||||
except aiohttp.errors.WSServerHandshakeError:
|
||||
except aiohttp.WSServerHandshakeError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -157,7 +157,6 @@ class ProjectHandler:
|
||||
response.set_status(200)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
|
||||
response.start(request)
|
||||
queue = project.get_listen_queue()
|
||||
@@ -240,11 +239,10 @@ class ProjectHandler:
|
||||
response.set_status(200)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
response.start(request)
|
||||
yield from response.prepare(request)
|
||||
while True:
|
||||
data = f.read(4096)
|
||||
if not data:
|
||||
@@ -274,7 +272,7 @@ class ProjectHandler:
|
||||
path = request.match_info["path"]
|
||||
path = os.path.normpath(path)
|
||||
|
||||
# Raise an error if user try to escape
|
||||
# Raise an error if user try to escape
|
||||
if path[0] == ".":
|
||||
raise aiohttp.web.HTTPForbidden
|
||||
path = os.path.join(project.path, path)
|
||||
@@ -283,11 +281,10 @@ class ProjectHandler:
|
||||
response.set_status(200)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
response.start(request)
|
||||
yield from response.prepare(request)
|
||||
while True:
|
||||
data = f.read(4096)
|
||||
if not data:
|
||||
@@ -358,8 +355,7 @@ class ProjectHandler:
|
||||
response.headers['CONTENT-DISPOSITION'] = 'attachment; filename="{}.gns3project"'.format(project.name)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
response.start(request)
|
||||
yield from response.prepare(request)
|
||||
|
||||
include_images = bool(int(request.json.get("include_images", "0")))
|
||||
for data in project.export(include_images=include_images):
|
||||
|
||||
@@ -179,8 +179,7 @@ class LinkHandler:
|
||||
response.set_status(200)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
response.start(request)
|
||||
yield from response.prepare(request)
|
||||
|
||||
while True:
|
||||
chunk = f.read(4096)
|
||||
|
||||
@@ -351,8 +351,7 @@ class NodeHandler:
|
||||
response.set_status(200)
|
||||
response.content_type = "application/octet-stream"
|
||||
response.enable_chunked_encoding()
|
||||
response.content_length = None
|
||||
response.start(request)
|
||||
yield from response.prepare(request)
|
||||
|
||||
response.write(res.body)
|
||||
yield from response.write_eof()
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
import os
|
||||
import aiohttp
|
||||
import aiohttp.errors
|
||||
import asyncio
|
||||
import tempfile
|
||||
|
||||
@@ -47,7 +46,7 @@ def process_websocket(ws):
|
||||
"""
|
||||
try:
|
||||
yield from ws.receive()
|
||||
except aiohttp.errors.WSServerHandshakeError:
|
||||
except aiohttp.WSServerHandshakeError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -212,9 +211,8 @@ class ProjectHandler:
|
||||
response.set_status(200)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
|
||||
response.start(request)
|
||||
yield from response.prepare(request)
|
||||
with controller.notification.queue(project) as queue:
|
||||
while True:
|
||||
try:
|
||||
@@ -295,8 +293,7 @@ class ProjectHandler:
|
||||
response.headers['CONTENT-DISPOSITION'] = 'attachment; filename="{}.gns3project"'.format(project.name)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
response.start(request)
|
||||
yield from response.prepare(request)
|
||||
|
||||
for data in datas:
|
||||
response.write(data)
|
||||
@@ -408,11 +405,10 @@ class ProjectHandler:
|
||||
response.set_status(200)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
response.start(request)
|
||||
yield from response.prepare(request)
|
||||
while True:
|
||||
data = f.read(4096)
|
||||
if not data:
|
||||
|
||||
Reference in new issue
Block a user