mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-11 01:28:09 +00:00
Fix streaming of pcap file
This commit is contained in:
parent
4bbd8938ab
commit
6a259c7e06
@ -15,6 +15,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
from gns3server.web.route import Route
|
from gns3server.web.route import Route
|
||||||
@ -160,7 +161,7 @@ class LinkHandler:
|
|||||||
"project_id": "Project UUID",
|
"project_id": "Project UUID",
|
||||||
"link_id": "Link UUID"
|
"link_id": "Link UUID"
|
||||||
},
|
},
|
||||||
description="Steam the pcap capture file",
|
description="Stream the pcap capture file",
|
||||||
status_codes={
|
status_codes={
|
||||||
200: "File returned",
|
200: "File returned",
|
||||||
403: "Permission denied",
|
403: "Permission denied",
|
||||||
@ -188,7 +189,7 @@ class LinkHandler:
|
|||||||
while True:
|
while True:
|
||||||
chunk = f.read(4096)
|
chunk = f.read(4096)
|
||||||
if not chunk:
|
if not chunk:
|
||||||
break
|
yield from asyncio.sleep(0.1)
|
||||||
yield from response.write(chunk)
|
yield from response.write(chunk)
|
||||||
except OSError:
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user