Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an optional redirect(cache=sec) argument #1370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

da2x
Copy link

@da2x da2x commented Apr 14, 2022

The argument sets an optional Cache-Control header for redirects. Allows for more fined-grained control over client and browser caching for known short- and long-lived redirects. The argument accepts an integer value with the number of seconds to add to the max-age directive. Browser support: universal.

The argument sets an optional Cache-Control header for redirects. Allows for
more fined-grained control over browser caching for known short- and long-
lived redirects.
Copy link
Member

@avelino avelino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to write doc and test validating the functioning of your implementation

""" Aborts execution and causes a 303 or 302 redirect, depending on
the HTTP protocol version. """
if not code:
code = 303 if request.get('SERVER_PROTOCOL') == "HTTP/1.1" else 302
res = response.copy(cls=HTTPResponse)
res.status = code
if type(cache) is int:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check if the variable exists, you don't need to look at its type.
If it is an unexpected string it will be the developer's responsibility

@avelino avelino added Feature This is a feature request, not a bug. Open for discussion. Needs tests This feature or fix needs a test-case to ensure it continues to work in the future. Needs docs This feature lacks documentation labels May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature This is a feature request, not a bug. Open for discussion. Needs docs This feature lacks documentation Needs tests This feature or fix needs a test-case to ensure it continues to work in the future.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants