-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The http status of the response is changed from 301 (Moved Permanently) to 302 (Found) for GET requests and to 307 (Temporary Redirect) for other request methods because nothing prevents the URL to be reused in the future. This was inspired by plone/plone.rest#76 Refs #8
- Loading branch information
Showing
3 changed files
with
21 additions
and
10 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The http status of the response is changed from 301 (Moved Permanently) to 302 (Found) for GET requests and to 307 (Temporary Redirect) for other request methods because nothing prevents the URL to be reused in the future. [ale-rt] |
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 |
---|---|---|
|
@@ -84,7 +84,17 @@ def attempt_redirect(self): | |
# some analytics programs might use this info to track | ||
if query_string: | ||
url += "?" + query_string | ||
self.request.response.redirect(url, status=301, lock=1) | ||
|
||
# Answer GET requests with 302 (Found). Every other method will be answered | ||
# with 307 (Temporary Redirect), which instructs the client to NOT | ||
# switch the method (if the original request was a POST, it should | ||
# re-POST to the new URL from the Location header). | ||
if self.request.method.upper() == "GET": | ||
status = 302 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
garaolaza
|
||
else: | ||
status = 307 | ||
|
||
self.request.response.redirect(url, status=status, lock=1) | ||
return True | ||
|
||
def find_redirect_if_view(self, old_path_elements, storage): | ||
|
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
@ale-rt why did we changed this from a
301
to a302
redirect?plone.rest example is used as an argument to issue a
307
forPOST
requests, but here we changed from "permanent" to "temporary" redirects when in plone.rest we keep having "permanents"@garaolaza @libargutxi