def testValidOptionsRequest(self):
"""
Makes sure that a "regular" OPTIONS request doesn't include the CORS
specific headers in the response.
"""
agent = Agent(reactor)
headers = Headers({'origin': ['http://localhost']})
response = yield agent.request('OPTIONS', self.uri, headers)
# Check we get the correct status.
self.assertEqual(http.OK, response.code)
# Check we get the correct length
self.assertEqual(0, response.length)
# Check we get the right headers back
self.assertTrue(response.headers.hasHeader('Allow'))
self.assertFalse(
response.headers.hasHeader('Access-Control-Allow-Origin'))
self.assertFalse(response.headers.hasHeader('Access-Control-Max-Age'))
self.assertFalse(
response.headers.hasHeader('Access-Control-Allow-Credentials'))
self.assertFalse(
response.headers.hasHeader('Access-Control-Allow-Methods'))
评论列表
文章目录