Check content type by completely match instead of partial match
Currently, 'get_content_type' method in neutron/wsgi.py checks specified format by 'in' statement. Thus, string(e.g. 'application/j') that is partial matched to 'application/json' is returned. However, we cannot find valid serializer from the format, and request fails with unexpected error. Change-Id: I75aac0308d0fd0321973c4bda3bc07ca0224e1c1 Closes-Bug: #1612485
This commit is contained in:
parent
b555eed7fa
commit
e99274397c
|
@ -43,6 +43,12 @@ class RequestTestCase(base.BaseTestCase):
|
|||
result = request.get_content_type()
|
||||
self.assertEqual("application/json", result)
|
||||
|
||||
def test_content_type_with_partial_matched_string(self):
|
||||
request = wsgi.Request.blank('/tests/123')
|
||||
request.headers["Content-Type"] = "application/j"
|
||||
result = request.best_match_content_type()
|
||||
self.assertEqual("application/json", result)
|
||||
|
||||
def test_content_type_from_accept(self):
|
||||
content_type = 'application/json'
|
||||
request = wsgi.Request.blank('/tests/123')
|
||||
|
|
|
@ -252,7 +252,7 @@ class Request(wsgi.Request):
|
|||
return bm or 'application/json'
|
||||
|
||||
def get_content_type(self):
|
||||
allowed_types = ("application/json")
|
||||
allowed_types = ("application/json",)
|
||||
if "Content-Type" not in self.headers:
|
||||
LOG.debug("Missing Content-Type")
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue