summaryrefslogtreecommitdiffstats
path: root/multivimbroker
diff options
context:
space:
mode:
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)