-
Notifications
You must be signed in to change notification settings - Fork 61
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
Update several status codes to RFC 9110 #197
Conversation
I'm going to close and re-open to see if that starts CI. |
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.
We need a proper way to fix HTTP_UNUSED
lib/HTTP/Status.pm
Outdated
414 => 'URI Too Long', | ||
415 => 'Unsupported Media Type', | ||
416 => 'Range Not Satisfiable', # RFC 7233: Range Requests | ||
417 => 'Expectation Failed', | ||
# 418 .. 420 | ||
418 => "I'm a teapot", # RFC 9110: Its official now -sorta |
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.
the registry indicates that it is (Unused)
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.
Yes. However becauee of the HTTP_UNUSED being there twixe I opted for keeping the Teapot reference. Also because the RFC refers to this fact as the reason why it assigned.
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.
As much as it hurts my personal feeling that I'm a Teapot
will be gone, I prefer correctness above sentiment, and let's stick with (Unused)
:-(
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.
I get what you are saying, but I do think this easter egg or April's day can stay. But you're in charge, so I'll remove it.
I've done some middle grounding based on another comment of yours in this PR.
In the compat section, when you call I_AM_A_TEAPOT, we set the status code of 418 to I'm a teapot
and from that moment onwards you have the status message as I'm a teapot
. It keeps the easter egg alive and kicking for those who get a little giggle out of it (myself included) and when you don't use it it stays (Unused)
. And we are skipping HTTP_UNUSED from being exported/implemented.
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.
Not sure if we had Easter on 1-April in that year to0 ... butt yes, this is what I prefer, for those that ever used it to keep it alive.
What about the following: set the %StatusCodes like: 306 => '(Unused)', # RFC 9110: Previously used and reserved
418 => '(Unused)', # RFC 9110: Its official now -sorta
# 419 .. 420 my %compat = (
I_AM_A_TEAPOT => sub {
carp "HTTP Status Code 418 set to \"I'm a Teapot\"\n"
$StatusCode{418} = "I'm a teapot";
418
},
NO_CODE => \&HTTP_TOO_EARLY,
PAYLOAD_TOO_LARGE => \&HTTP_CONTENT_TOO_LARGE,
REQUEST_ENTITY_TOO_LARGE => \&HTTP_CONTENT_TOO_LARGE,
REQUEST_RANGE_NOT_SATISFIABLE => \&HTTP_RANGE_NOT_SATISFIABLE,
REQUEST_URI_TOO_LARGE => \&HTTP_URI_TOO_LONG,
UNPROCESSABLE_ENTITY => \&HTTP_UNPROCESSABLE_CONTENT,
UNORDERED_COLLECTION => \&HTTP_TOO_EARLY,
UNUSED => sub {
carp "HTTP Status Code '(Unused)'\n";
000
},
); That way, for those who fancy the 🫖 , it is still there when once used as Please be advised, that Just some ideas... |
I think it would be better to remove the constants for the "unused" codes. That eliminates the ambiguity between 306 and 418. |
I am totally fine with removing (or preferably not adding) the But unlike non registered codes that will return |
f8f000d
to
1c94d56
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.
LGTM
lib/HTTP/Status.pm
Outdated
@@ -121,7 +118,13 @@ die if $@; | |||
push(@EXPORT, "RC_MOVED_TEMPORARILY"); | |||
|
|||
my %compat = ( | |||
REQUEST_ENTITY_TOO_LARGE => \&HTTP_PAYLOAD_TOO_LARGE, | |||
I_AM_A_TEAPOT => sub { | |||
$StatusCode{418} = "I'm a teapot"; |
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.
This is a really terrible idea. Changing global behavior based on a constant access should never happen. This should just return 418 and do nothing else.
The prototype also needs to be ()
.
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.
Good catch, about the prototype
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.
it is a terrible idea, but so is it to just change the registry.
I would like to avoid the surprise:
say status_message HTTP_I_AM_A_TEAPOT; # (Unused)
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.
If that is a large concern, just leave the message as "I'm a teapot".
The likelihood of anyone actually relying on 418 is very small.
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.
We use it in Production, and I often use it when developers can't get an agreement on the exact 4xx status
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.
And you are relying on what the message is?
There's just no way you can have this both ways. The message should either be (Unused)
or I'm a teapot
. I don't think it's particularly important which one. You can't do both. Trying to do both will make the result unpredictable and anything that relies on it will always be broken in some cases.
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.
I favor the teapot, but if you want it to be unused, I'll go with that.
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.
If we need to decide on one and the status code is unused anyway, I'm in favour of 🫖.
* 306 is officially reserved but unused * 413 is called 'Content Too Large' in RFC 9110 * 418 is officially reserved, so let's make it official here too * 422 is imported from WebDAV and named 'Unprocessable Content'. Reference: https://www.rfc-editor.org/rfc/rfc9110.html#name-changes-from-rfc-7231 Signed-off-by: Wesley Schwengle <[email protected]>
Any update on this PR? |
Close and re-open to kick off CI. |
Thanks, @waterkip! |
Reference: https://www.rfc-editor.org/rfc/rfc9110.html#name-changes-from-rfc-7231