summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Lynn <ethanlynnl@vmware.com>2018-04-02 14:08:49 +0800
committerEthan Lynn <ethanlynnl@vmware.com>2018-04-02 14:22:30 +0800
commitdd5aa4a740e7a75acacba3623e36ef08b740e8e0 (patch)
tree6f40f8420ec4443a0dfcdbf87409c9b7a350912e
parenta2303cd2db3dd71ed1d02b19ef15ed7de5505271 (diff)
Fix header handler for forwarder
This patch fix an error when forwarder got an connection error. Change-Id: Ide2941a3447582aa282f2b785e9356ad17e9a518 Issue-ID: MULTICLOUD-209 Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
-rw-r--r--multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py6
-rw-r--r--multivimbroker/multivimbroker/forwarder/base.py5
-rw-r--r--multivimbroker/multivimbroker/pub/utils/restcall.py2
3 files changed, 7 insertions, 6 deletions
diff --git a/multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py b/multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py
index 99c1b08..a158c42 100644
--- a/multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py
+++ b/multivimbroker/multivimbroker/api_v2/api_router/v0_controller.py
@@ -86,8 +86,8 @@ class V0_Controller(object):
logger.error("Status code is %s, detail is %s.",
status_code, content)
response = pecan.Response(body=content, status=status_code)
-
- for k in syscomm.getHeadersKeys(resp):
- response.headers[k] = resp[k]
+ if retcode == 0:
+ for k in syscomm.getHeadersKeys(resp):
+ response.headers[k] = resp[k]
return response
diff --git a/multivimbroker/multivimbroker/forwarder/base.py b/multivimbroker/multivimbroker/forwarder/base.py
index 512bb6a..6d45014 100644
--- a/multivimbroker/multivimbroker/forwarder/base.py
+++ b/multivimbroker/multivimbroker/forwarder/base.py
@@ -48,8 +48,9 @@ class BaseHandler(object):
logger.exception("exception: %s" % e)
response = HttpResponse(content, status=status_code)
- for k in getHeadersKeys(resp):
- response[k] = resp[k]
+ if retcode == 0:
+ for k in getHeadersKeys(resp):
+ response[k] = resp[k]
return response
def _multipart_req(self, route_uri, method, body, headers=None):
diff --git a/multivimbroker/multivimbroker/pub/utils/restcall.py b/multivimbroker/multivimbroker/pub/utils/restcall.py
index 046d77c..a136353 100644
--- a/multivimbroker/multivimbroker/pub/utils/restcall.py
+++ b/multivimbroker/multivimbroker/pub/utils/restcall.py
@@ -69,7 +69,7 @@ def call_req(base_url, user, passwd, auth_type, resource, method,
# logger.debug("[%s]call_req('%s','%s','%s',%s,'%s','%s','%s')" % (
# callid, base_url, user, passwd, auth_type, resource, method, content))
ret = None
- resp_status = ''
+ resp_status = '500'
resp = ""
full_url = ""