Skip to content

Commit

Permalink
Change normalize_path_middleware redirect from 301 -> 308 (#3579)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtkav authored and asvetlov committed Jun 11, 2019
1 parent bd92303 commit b80fec6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES/3579.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Change normalize_path_middleware to use 308 redirect instead of 301.

This behavior should prevent clients from being unable to use PUT/POST
methods on endpoints that are redirected because of a trailing slash.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Cong Xu
Damien Nadé
Dan Xu
Daniel García
Daniel Grossmann-Kavanagh
Daniel Nelson
Danny Song
David Bibb
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/web_middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import warnings
from typing import TYPE_CHECKING, Awaitable, Callable, Tuple, Type, TypeVar

from .web_exceptions import HTTPMove, HTTPMovedPermanently
from .web_exceptions import HTTPMove, HTTPPermanentRedirect
from .web_request import Request
from .web_response import StreamResponse
from .web_urldispatcher import SystemRoute
Expand Down Expand Up @@ -45,7 +45,7 @@ def middleware(f: _Func) -> _Func:
def normalize_path_middleware(
*, append_slash: bool=True, remove_slash: bool=False,
merge_slashes: bool=True,
redirect_class: Type[HTTPMove]=HTTPMovedPermanently) -> _Middleware:
redirect_class: Type[HTTPMove]=HTTPPermanentRedirect) -> _Middleware:
"""
Middleware factory which produces a middleware that normalizes
the path of a request. By normalizing it means:
Expand Down
2 changes: 1 addition & 1 deletion docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2826,7 +2826,7 @@ Normalize path middleware
append_slash=True, \
remove_slash=False, \
merge_slashes=True, \
redirect_class=HTTPMovedPermanently)
redirect_class=HTTPPermanentRedirect)

Middleware factory which produces a middleware that normalizes
the path of a request. By normalizing it means:
Expand Down

0 comments on commit b80fec6

Please sign in to comment.