Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes set_cors_headers method in core.py compatible with resp.head… (#…
…172) * Made the set_cors_headers method in core.py compatible with resp.headers objects that are standard python dicts, by copying the underlying data into a new MultiDict.
- Loading branch information
1 parent
7a82aeb
commit aaaf904
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
test | ||
~~~~ | ||
Flask-Cors tests module | ||
""" | ||
|
||
from ..base_test import FlaskCorsTestCase | ||
from flask import Flask, Response | ||
|
||
from flask_cors import * | ||
from flask_cors.core import * | ||
|
||
class ResponseHeadersOverrideTestCaseIntegration(FlaskCorsTestCase): | ||
def setUp(self): | ||
self.app = Flask(__name__) | ||
CORS(self.app) | ||
|
||
@self.app.route('/') | ||
def index(): | ||
response = Response(headers={"custom": "dictionary"}) | ||
return 'Welcome' | ||
|
||
def test_override_headers(self): | ||
''' | ||
Ensure we work even if response.headers is set to something other than a MultiDict. | ||
''' | ||
for resp in self.iter_responses('/'): | ||
self.assertTrue(ACL_ORIGIN in resp.headers) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |