-
Notifications
You must be signed in to change notification settings - Fork 501
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 HTTP status helper class #833
Conversation
11f6958
to
cca92a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed. Left a few notes. Nothing major.
184208a
to
617a5df
Compare
617a5df
to
9a3ee12
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, left a few notes inline. Nothing major.
e4ec849
to
b66215b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your work on this @schlessera ! LGTM.
I've added two small commits still with some very minor nitpicks (mostly CS).
Do you want to clean up the branch before merge ? Or shall I merge it as is ?
P.S.: build failures are due to GH having trouble. We'll probably best restart them once GH has recovered. |
47cda6a
to
05df33a
Compare
This class provides constants with the available HTTP status codes with thorough documentation based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Status. It also comes with helper functions get_text($code) and is_valid_code($code) to simplify consuming code.
05df33a
to
451f7b0
Compare
Yippia-a-yeah! Ready for merge once the build finishes. |
This PR adds a utility class to deal with HTTP status codes and messages and then changes existing code in
Http
exceptions and theTransportMock
to make use of this utility class.Pull Request Type
This is a:
Context
PR #582 added a new
TransportRedirectMock
which was based onTransportMock
. While doing so, it needed to duplicate the long list of status code messages already included inTransportMock
. To make this process easier and simplify maintenance, we decided to extract knowledge about HTTP status codes and texts into a separate utility class instead, making both transport mock classes simpler in the process.Detailed Description
The new helper class
HttpStatus
contains two methods:get_text($code)
retrieves a status text from a status codeis_valid_code($code)
returns a boolean on whether a given code is a valid (known) status codeThe helper class also contains constants that can be directly referenced, like so:
The PR updates all
Http
exceptions to make use of this to de-duplicate the status text strings.Quality assurance
Documentation
For new features:
examples
directory.docs
directory.If the documentation is in a new markdown file, I have added a link to this new file to the Docs folder
README.md
file.