Skip to content

Commit

Permalink
Made the set_cors_headers method in core.py compatible with resp.head…
Browse files Browse the repository at this point in the history
…ers objects that are standard python dicts, by copying the underlying data into a new MultiDict.
  • Loading branch information
BillBrower committed Aug 16, 2016
1 parent 7a82aeb commit b45aa4a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions flask_cors/core.py
Expand Up @@ -226,6 +226,14 @@ def set_cors_headers(resp, options):
LOG.debug('CORS have been already evaluated, skipping')
return resp

# If resp.headers is not a MultiDict, set resp.headers to a new
# MultiDict, copying the underlying dict.
if type(resp.headers) is MultiDict:
multidict = MultiDict()
for k, v in resp.headers.items():
multidict.add(k, v)
resp.headers = multidict

headers_to_set = get_cors_headers(options, request.headers, request.method)

LOG.debug('Settings CORS headers: %s', str(headers_to_set))
Expand Down

0 comments on commit b45aa4a

Please sign in to comment.