Skip to content

Commit

Permalink
Add type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Wilson committed Dec 11, 2020
1 parent b2d8b37 commit ba3fe37
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions starlette/middleware/cors.py
Expand Up @@ -157,16 +157,16 @@ async def send(
# If request includes any cookie headers, then we must respond
# with the specific origin instead of '*'.
if self.allow_all_origins and has_cookie:
self.allow_explicit_origin(origin, headers)
self.allow_explicit_origin(headers, origin)

# If we only allow specific origins, then we have to mirror back
# the Origin header in the response.
elif not self.allow_all_origins and self.is_allowed_origin(origin=origin):
self.allow_explicit_origin(origin, headers)
self.allow_explicit_origin(headers, origin)

await send(message)

@staticmethod
def allow_explicit_origin(origin, headers):
def allow_explicit_origin(headers: MutableHeaders, origin: str) -> None:
headers["Access-Control-Allow-Origin"] = origin
headers.add_vary_header("Origin")

0 comments on commit ba3fe37

Please sign in to comment.