mirror of
https://github.com/GNS3/gns3-gui.git
synced 2026-05-17 00:46:01 +03:00
Fix permission error when importing a project on a remote server
Fix #2082
This commit is contained in:
@@ -467,6 +467,22 @@ class HTTPClient(QtCore.QObject):
|
||||
host = self._host
|
||||
return host
|
||||
|
||||
def _paramsToQueryString(self, params):
|
||||
"""
|
||||
:param params: Dictionnary of query string parameters
|
||||
:returns: String of the query string
|
||||
"""
|
||||
if params == {}:
|
||||
query_string = ""
|
||||
else:
|
||||
query_string = "?"
|
||||
params = params.copy()
|
||||
for key, value in params.copy().items():
|
||||
if value is None:
|
||||
del params[key]
|
||||
query_string += urllib.parse.urlencode(params)
|
||||
return query_string
|
||||
|
||||
def _executeHTTPQuery(self, method, path, callback, body, context={}, downloadProgressCallback=None, showProgress=True, ignoreErrors=False, progressText=None, server=None, timeout=120, prefix="/v2", params={}, networkManager=None, **kwargs):
|
||||
"""
|
||||
Call the remote server
|
||||
@@ -488,10 +504,7 @@ class HTTPClient(QtCore.QObject):
|
||||
"""
|
||||
|
||||
host = self._getHostForQuery()
|
||||
if params == {}:
|
||||
query_string = ""
|
||||
else:
|
||||
query_string = "?" + urllib.parse.urlencode(params)
|
||||
query_string = self._paramsToQueryString(params)
|
||||
|
||||
log.debug("{method} {protocol}://{host}:{port}{prefix}{path} {body}{query_string}".format(method=method, protocol=self._protocol, host=host, port=self._port, path=path, body=body, prefix=prefix, query_string=query_string))
|
||||
if self._user:
|
||||
|
||||
@@ -79,6 +79,14 @@ def test_get_connected(http_client, http_request, network_manager, response):
|
||||
assert callback.called
|
||||
|
||||
|
||||
def test_paramsToQueryString(http_client):
|
||||
assert http_client._paramsToQueryString({}) == ""
|
||||
res = http_client._paramsToQueryString({"a": 1, "b": 2})
|
||||
assert res == "?a=1&b=2" or res == "?b=2&a=1"
|
||||
res = http_client._paramsToQueryString({"a": 1, "b": 2, "c": None})
|
||||
assert res == "?a=1&b=2" or res == "?b=2&a=1"
|
||||
|
||||
|
||||
def test_get_connected_auth(http_client, http_request, network_manager, response):
|
||||
|
||||
http_client._connected = True
|
||||
|
||||
Reference in New Issue
Block a user