Skip to content

Commit

Permalink
Fix the GUI disconnect from the server
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-duponchelle committed May 31, 2017
1 parent 89394ba commit 7044c8c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 0 additions & 4 deletions gns3server/handlers/api/compute/project_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def notification(request, response):
response.content_type = "application/json"
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.start(request)
queue = project.get_listen_queue()
Expand Down Expand Up @@ -238,7 +237,6 @@ def get_file(request, response):
response.content_type = "application/octet-stream"
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)

try:
with open(path, "rb") as f:
Expand Down Expand Up @@ -280,7 +278,6 @@ def stream_file(request, response):
response.content_type = "application/octet-stream"
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)

try:
with open(path, "rb") as f:
Expand Down Expand Up @@ -354,7 +351,6 @@ def export_project(request, response):
response.content_type = 'application/gns3project'
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)
yield from response.prepare(request)

include_images = bool(int(request.json.get("include_images", "0")))
Expand Down
1 change: 0 additions & 1 deletion gns3server/handlers/api/controller/link_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def pcap(request, response):
response.content_type = "application/vnd.tcpdump.pcap"
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)
yield from response.prepare(request)

while True:
Expand Down
3 changes: 0 additions & 3 deletions gns3server/handlers/api/controller/project_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def notification(request, response):
response.content_type = "application/json"
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)

yield from response.prepare(request)
with controller.notification.queue(project) as queue:
Expand Down Expand Up @@ -292,7 +291,6 @@ def export_project(request, response):
response.content_type = 'application/gns3project'
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)
yield from response.prepare(request)

for data in datas:
Expand Down Expand Up @@ -404,7 +402,6 @@ def get_file(request, response):
response.content_type = "application/octet-stream"
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)

try:
with open(path, "rb") as f:
Expand Down
5 changes: 5 additions & 0 deletions gns3server/web/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def __init__(self, request=None, route=None, output_schema=None, headers={}, **k
headers['Server'] = "Python/{0[0]}.{0[1]} GNS3/{1}".format(sys.version_info, __version__)
super().__init__(headers=headers, **kwargs)

def 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
super().enable_chunked_encoding()

@asyncio.coroutine
def prepare(self, request):
if log.getEffectiveLevel() == logging.DEBUG:
Expand Down

0 comments on commit 7044c8c

Please sign in to comment.