Skip to content

Commit

Permalink
Alternative fix for GUI connection to server. Ref GNS3/gns3-server#2411
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Nov 17, 2024
1 parent 5fbba82 commit 45f5155
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gns3/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 45f5155

Please sign in to comment.