fix(Response): Sets default OPTIONS responder Content-Length to 0 (#801)

* fix(Response): Sets default OPTIONS responder Content-Length to 0

Closes #796

* test(Response): Added test to check default content-length header for OPTIONS Request

It checks that the content-length header for options request is 0.
Closes #796
This commit is contained in:
Yash Mehrotra
2016-06-04 06:53:05 +05:30
committed by John Vrbanac
parent 8be4ced587
commit 5ef11c505a
2 changed files with 7 additions and 0 deletions

View File

@@ -58,5 +58,6 @@ def create_default_options(allowed_methods):
def on_options(req, resp, **kwargs):
resp.status = HTTP_204
resp.set_header('Allow', allowed)
resp.set_header('Content-Length', '0')
return on_options

View File

@@ -534,6 +534,12 @@ class TestHeaders(testing.TestCase):
self._check_link_header(resource, expected_value)
def test_content_length_options(self):
result = self.simulate_options()
content_length = '0'
self.assertEqual(result.headers['Content-Length'], content_length)
# ----------------------------------------------------------------------
# Helpers
# ----------------------------------------------------------------------