Normalize glanceclient requested service url
Some proxy or gateway softwares, e.g. jumpgate [0], use url-pattern based approach to match which hanlding logic needs to be triggered for particular service calling when it received a http(s) call as a middleman. The change fixed an issue which caused glanceclient send out the request to a dis-normal url, which contains duplicated "/". The change removed a wrong and duplicated code snippet from curl logging function as well. [0] http://goo.gl/yt52X1 Change-Id: Ic8b3920e11d400771ead7f9c44b615f10b4a5cef Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
This commit is contained in:
@@ -97,8 +97,6 @@ class HTTPClient(object):
|
|||||||
if data and isinstance(data, six.string_types):
|
if data and isinstance(data, six.string_types):
|
||||||
curl.append('-d \'%s\'' % data)
|
curl.append('-d \'%s\'' % data)
|
||||||
|
|
||||||
if "//:" not in url:
|
|
||||||
url = '%s%s' % (self.endpoint, url)
|
|
||||||
curl.append(url)
|
curl.append(url)
|
||||||
LOG.debug(strutils.safe_encode(' '.join(curl), errors='ignore'))
|
LOG.debug(strutils.safe_encode(' '.join(curl), errors='ignore'))
|
||||||
|
|
||||||
@@ -168,7 +166,10 @@ class HTTPClient(object):
|
|||||||
headers = self.encode_headers(headers)
|
headers = self.encode_headers(headers)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn_url = "%s/%s" % (self.endpoint, url)
|
if self.endpoint.endswith("/") or url.startswith("/"):
|
||||||
|
conn_url = "%s%s" % (self.endpoint, url)
|
||||||
|
else:
|
||||||
|
conn_url = "%s/%s" % (self.endpoint, url)
|
||||||
self.log_curl_request(method, conn_url, headers, data, kwargs)
|
self.log_curl_request(method, conn_url, headers, data, kwargs)
|
||||||
resp = self.session.request(method,
|
resp = self.session.request(method,
|
||||||
conn_url,
|
conn_url,
|
||||||
|
Reference in New Issue
Block a user