Skip to content

Commit

Permalink
chore: Change idempotent / non-idempotent methods constants to be tup…
Browse files Browse the repository at this point in the history
…les, not frozensets.
  • Loading branch information
playpauseandstop committed Jul 22, 2019
1 parent 4d9dd55 commit 49557f6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ Changelog
0.2.0b2 (2019-07-21)
--------------------

- feature: Add ``cors_middleware`` to simplify handling CORS policies for
- feature: Add ``cors_middleware`` to simplify handling CORS headers for
aiohttp apps comparing to `aiohttp-cors
<https://github.com/aio-libs/aiohttp-cors>`_ library
- chore: ``IDEMPOTENT_METHODS`` and ``NON_IDEMPOTENT_METHODS`` are now tuple
of strings, not frozenset

0.2.0b1 (2019-07-19)
--------------------
Expand Down
8 changes: 4 additions & 4 deletions aiohttp_middlewares/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

#: Set of idempotent HTTP methods
IDEMPOTENT_METHODS = frozenset({"GET", "HEAD", "OPTIONS", "TRACE"})
#: Tuple of idempotent HTTP methods
IDEMPOTENT_METHODS = ("GET", "HEAD", "OPTIONS", "TRACE")

#: Set of non-idempotent HTTP methods
NON_IDEMPOTENT_METHODS = frozenset({"DELETE", "PATCH", "POST", "PUT"})
#: Tuple of non-idempotent HTTP methods
NON_IDEMPOTENT_METHODS = ("DELETE", "PATCH", "POST", "PUT")
32 changes: 14 additions & 18 deletions aiohttp_middlewares/cors.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,18 @@
ACCESS_CONTROL_MAX_AGE = f"{ACCESS_CONTROL}-Max-Age"
ACCESS_CONTROL_REQUEST_METHOD = f"{ACCESS_CONTROL}-Request-Method"

DEFAULT_ALLOW_HEADERS = frozenset(
[
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"x-csrftoken",
"x-requested-with",
]
)
DEFAULT_ALLOW_METHODS = frozenset(
["DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT"]
DEFAULT_ALLOW_HEADERS = (
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"x-csrftoken",
"x-requested-with",
)
DEFAULT_ALLOW_METHODS = ("DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT")
DEFAULT_URLS = (re.compile(r".*"),)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -168,7 +164,7 @@ def cors_middleware(
.. code-block:: python
[
(
"accept",
"accept-encoding",
"authorization",
Expand All @@ -178,14 +174,14 @@ def cors_middleware(
"user-agent",
"x-csrftoken",
"x-requested-with",
]
)
:param allow_methods:
List of allowed methods. By default:
.. code-block:: python
["DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT"]
("DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT")
:param allow_credentials:
When enabled apply allow credentials header in response, which results
Expand Down

0 comments on commit 49557f6

Please sign in to comment.