summaryrefslogtreecommitdiffstats
path: root/multivimbroker
diff options
context:
space:
mode:
authorEthan Lynn <ethanlynnl@vmware.com>2018-05-10 13:51:43 +0800
committerEthan Lynn <ethanlynnl@vmware.com>2018-05-10 13:54:14 +0800
commit03056c2a987eb89129d5f2533fc78dffc73c2481 (patch)
tree0a56ae6fcb32a6eefe2bccca34d51d6512e6dd53 /multivimbroker
parent0e39e0363e1008d4f162b247747d8bbecffd7ae1 (diff)
Support forward "content-type" header
Forward "content-type" in request headers Change-Id: Iac920045534aafb10a31cc21ebb95a436104c5b7 Issue-ID: MULTICLOUD-229 Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
Diffstat (limited to 'multivimbroker')
-rw-r--r--multivimbroker/multivimbroker/pub/utils/syscomm.py11
-rw-r--r--multivimbroker/multivimbroker/tests/test_syscomm.py6
2 files changed, 11 insertions, 6 deletions
diff --git a/multivimbroker/multivimbroker/pub/utils/syscomm.py b/multivimbroker/multivimbroker/pub/utils/syscomm.py
index 7a45395..9e96d2e 100644
--- a/multivimbroker/multivimbroker/pub/utils/syscomm.py
+++ b/multivimbroker/multivimbroker/pub/utils/syscomm.py
@@ -38,10 +38,13 @@ def getHeadersKeys(response):
# trim out 'HTTP_' prefix part and replace "_" wiht "-".
def originHeaders(request):
- regex = re.compile('^HTTP_')
- return dict((regex.sub('', header).replace("_", "-"), value)
- for (header, value) in request.META.items()
- if header.startswith('HTTP_'))
+ headers = {}
+ for key, value in request.META.items():
+ if key.startswith('HTTP_') and key != 'HTTP_HOST':
+ headers[key[5:].replace('_', '-')] = value
+ elif key in ('CONTENT_TYPE', 'CONTENT_LENGTH'):
+ headers[key.replace('_', '-')] = value
+ return headers
def findMultivimDriver(vim=None):
diff --git a/multivimbroker/multivimbroker/tests/test_syscomm.py b/multivimbroker/multivimbroker/tests/test_syscomm.py
index e28c2c7..1a5017c 100644
--- a/multivimbroker/multivimbroker/tests/test_syscomm.py
+++ b/multivimbroker/multivimbroker/tests/test_syscomm.py
@@ -57,10 +57,12 @@ class TestSyscomm(unittest.TestCase):
req = mock.Mock()
req.META = {
"HTTP_X_AUTH_TOKEN": "token_1",
- "NOT_STARTSWITH_HTTP": "value_1"
+ "NOT_STARTSWITH_HTTP": "value_1",
+ "CONTENT_TYPE": "application/json"
}
expect_headers = {
- "X-AUTH-TOKEN": "token_1"
+ "X-AUTH-TOKEN": "token_1",
+ "CONTENT-TYPE": "application/json"
}
ret_headers = syscomm.originHeaders(req)
self.assertDictEqual(expect_headers, ret_headers)