From 45f5155efc5c314cd215d444ed489d23829da100 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 17 Nov 2024 11:45:32 +1000 Subject: [PATCH] Alternative fix for GUI connection to server. Ref https://github.com/GNS3/gns3-server/issues/2411 --- gns3/http_client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gns3/http_client.py b/gns3/http_client.py index cf690c794..de8970cdd 100644 --- a/gns3/http_client.py +++ b/gns3/http_client.py @@ -474,7 +474,7 @@ def _dataReadySlot(self, reply, callback, context): content_type = reply.header(QtNetwork.QNetworkRequest.ContentTypeHeader) if content_type == "application/json": content = content.decode("utf-8") - if "query_id" in context and context["query_id"] in self._buffer: + if context["query_id"] in self._buffer: content = self._buffer[context["query_id"]] + content try: while True: @@ -483,6 +483,7 @@ def _dataReadySlot(self, reply, callback, context): callback(answer, context=context) content = content[index:] except ValueError: # Partial JSON + print(content) self._buffer[context["query_id"]] = content else: callback(content, context=context) @@ -725,7 +726,9 @@ def _executeHTTPQuery( if context: context = copy.copy(context) - context["query_id"] = str(uuid.uuid4()) + else: + context = dict() + context["query_id"] = str(uuid.uuid4()) if download_progress_callback is not None: reply.readyRead.connect(qpartial(self._dataReadySlot, reply, download_progress_callback, context))