From 6a259c7e0667164b7be8d5064e4e07b8518f5185 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Fri, 2 Sep 2016 10:54:20 +0200 Subject: [PATCH] Fix streaming of pcap file --- gns3server/handlers/api/controller/link_handler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gns3server/handlers/api/controller/link_handler.py b/gns3server/handlers/api/controller/link_handler.py index 654f021b..462302bb 100644 --- a/gns3server/handlers/api/controller/link_handler.py +++ b/gns3server/handlers/api/controller/link_handler.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import asyncio import aiohttp from gns3server.web.route import Route @@ -160,7 +161,7 @@ class LinkHandler: "project_id": "Project UUID", "link_id": "Link UUID" }, - description="Steam the pcap capture file", + description="Stream the pcap capture file", status_codes={ 200: "File returned", 403: "Permission denied", @@ -188,7 +189,7 @@ class LinkHandler: while True: chunk = f.read(4096) if not chunk: - break + yield from asyncio.sleep(0.1) yield from response.write(chunk) except OSError: - raise aiohttp.web.HTTPNotFound(text="pcap file {} not found or not accessible".format(link.capture_file_path)) + raise aiohttp.web.HTTPNotFound(text="pcap file {} not found or not accessible".format(link.capture_file_path))