@@ -62,7 +62,7 @@ class Connection(object):
6262 TRACE_ALL = "all"
6363 PLATFORMS = {
6464 "Jetty" : "linux" ,
65- "nginx/1.17.8 " : "linux" ,
65+ "nginx" : "linux" ,
6666 "SelfHost" : "windows" ,
6767 "Kestrel" : "windows" ,
6868 "Microsoft-HTTPAPI/2.0" : "connection_manager" ,
@@ -78,6 +78,7 @@ def __init__(
7878 verify_cert = False ,
7979 trace = "none" ,
8080 script_watch = True ,
81+ url_prefix = None ,
8182 ):
8283 """Set the connection parameters to a rest server
8384
@@ -89,6 +90,7 @@ def __init__(
8990 ignore_env_proxy (bool):
9091 verify_cert (bool):
9192 script_watch (bool):
93+ url_prefix (str): the prefix that needs to added in the rest url
9294 """
9395 self .trace = trace
9496 if len (logging .getLogger (__name__ ).handlers ) == 0 :
@@ -135,6 +137,7 @@ def __init__(
135137 if ignore_env_proxy is True :
136138 os .environ ["no_proxy" ] = "*"
137139 self ._hostname = hostname
140+ self ._url_prefix = url_prefix
138141 if ":" in self ._hostname and "[" not in self ._hostname :
139142 self ._hostname = "[%s]" % self ._hostname
140143 self ._rest_port = rest_port
@@ -162,11 +165,19 @@ def _determine_test_tool_platform(self, platform):
162165 for rest_port in rest_ports :
163166 for scheme in ["http" , "https" ]:
164167 try :
165- url = "%s://%s:%s/api/v1/auth/session" % (
166- scheme ,
167- self ._hostname ,
168- rest_port ,
169- )
168+ if self ._url_prefix is not None :
169+ url = "%s://%s:%s/%s/api/v1/auth/session" % (
170+ scheme ,
171+ self ._hostname ,
172+ rest_port ,
173+ self ._url_prefix ,
174+ )
175+ else :
176+ url = "%s://%s:%s/api/v1/auth/session" % (
177+ scheme ,
178+ self ._hostname ,
179+ rest_port ,
180+ )
170181 payload = json .dumps ({"username" : "" , "password" : "" })
171182 headers = self ._headers
172183 headers ["content-type" ] = "application/json"
@@ -328,6 +339,8 @@ def _normalize_url(self, url):
328339 if ":" in hostname and "[" not in hostname :
329340 hostname = "[%s]" % hostname
330341 connection = "%s://%s:%s" % (self ._scheme , hostname , self ._rest_port )
342+ if self ._url_prefix is not None :
343+ connection += "/" + self ._url_prefix
331344 if url .startswith (self ._scheme ) == False :
332345 url = "%s/%s" % (connection , url .strip ("/" ))
333346 path_start = url .find ("://" ) + 3
@@ -553,7 +566,13 @@ def _send_recv(self, method, url, payload=None):
553566 self ._async_operation .poll_headers = headers .copy ()
554567 self ._async_operation .async_response = response
555568 if self ._async_operation .request is None :
556- return self ._poll ()
569+ try :
570+ return self ._poll ()
571+ finally :
572+ self ._async_operation .request = None
573+ self ._async_operation .async_response = None
574+ self ._async_operation .poll_url = None
575+ self ._async_operation .poll_headers = None
557576
558577 while response .status_code == 409 :
559578 time .sleep (6 )
0 commit comments