Skip to content

Support 308 Permanent Redirect HTTP redirect#1794

Merged
webknjaz merged 3 commits intocherrypy:masterfrom
ingoogni:ingoogni-redirect-308
Jul 27, 2019
Merged

Support 308 Permanent Redirect HTTP redirect#1794
webknjaz merged 3 commits intocherrypy:masterfrom
ingoogni:ingoogni-redirect-308

Conversation

@ingoogni
Copy link
Contributor

@ingoogni ingoogni commented Jul 26, 2019

Recognize raise cherrypy.HTTPRedirect('/new_uri', 308) as a legitimate redirect.

Refs:

What kind of change does this PR introduce?

  • bug fix
  • feature
  • docs update
  • tests/coverage improvement
  • refactoring
  • other

What is the related issue number (starting with #)

N/A

What is the current behavior? (You can also link to an open issue here)

raise cherrypy.HTTPRedirect('/new_uri', 308) is not recognized as a redirect and causes a ValueError

What is the new behavior (if this is a feature change)?

raise cherrypy.HTTPRedirect('/new_uri', 308) works the same way as other HTTP codes for redirection.

Other information:

N/A

Checklist:

  • I think the code is well written
  • I wrote good commit messages
  • I have squashed related commits together after the changes have been approved
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • I used the same coding conventions as the rest of the project
  • The new code doesn't generate linter offenses
  • Documentation reflects the changes
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences

@webknjaz
Copy link
Member

webknjaz commented Jul 26, 2019

Thanks for your contribution @ingoogni!

FTR I've just restarted a failed job on AppVeyor (and it's green now).
I'll probably need to improve the commit message before merging.

May I ask you to add a test case covering this change, please?

@codecov

This comment has been minimized.

@webknjaz webknjaz changed the title Update _cperror.py Support 308 Moved Permanently HTTP status redirect Jul 26, 2019
Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

Should the default_status property be also updated?

@webknjaz webknjaz requested a review from jaraco July 26, 2019 14:10
@ingoogni
Copy link
Contributor Author

Thank @webknjaz Regarding default_status, for what I found 308 is either implemented properly in browsers / clients or not at all. I wouldn't add 308 to the default_redirect. If 308 is not implemented the client should fall back on their unknown status procedure and just render the message.
I'll look into a test case.

@webknjaz webknjaz changed the title Support 308 Moved Permanently HTTP status redirect Support 308 Permanent Redirect HTTP redirect Jul 27, 2019
@webknjaz
Copy link
Member

Apparently, the status text is Permanent Redirect: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308#Status

I've also checked the client behavior and found out that there's no user confirmation on the browser side so I've corrected that too.

@webknjaz webknjaz merged commit 9eac624 into cherrypy:master Jul 27, 2019
@webknjaz
Copy link
Member

Thanks @ingoogni!

@ingoogni
Copy link
Contributor Author

Thanks @webknjaz

@ingoogni ingoogni deleted the ingoogni-redirect-308 branch July 28, 2019 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants