Commit 6f3b10c8 authored by Prateek Nayak's avatar Prateek Nayak Committed by Abhilash Raj

Check request.content_type for None

parent de15b816
......@@ -27,6 +27,7 @@ REST
* REST API errors are now always formatted as JSON. (See !451)
* Failed request validations now return more verbose errors, like ``Enum`` types
return all acceptable values. (See !451)
* REST API accepts request with content type None (See !479)
Command line
......@@ -355,7 +355,8 @@ def get_request_params(request):
# We parse the request based on the content type. Falcon has a default
# JSONHandler handler to parse json media type, so we can just do
# `` to return the request params passed as json body.
if request.content_type.startswith('application/json'):
if (request.content_type and
return or dict()
# request.params returns the parameters passed as URL form encoded.
return request.params or dict()
......@@ -27,6 +27,12 @@ from import helpers
from mailman.testing.layers import ConfigLayer, RESTLayer
class FakeRequest:
def __init__(self):
self.content_type = None
self.params = 'not set'
class FakeResponse:
def __init__(self):
self.body = 'not set'
......@@ -162,6 +168,11 @@ class TestHelpers(unittest.TestCase):
{'title': '403 Forbidden',
'description': 'Conflicting request', })
def test_get_request_params_with_none(self):
request = FakeRequest()
'not set')
class TestJSONEncoder(unittest.TestCase):
"""Test the JSON ExtendedEncoder."""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment