Confusing/incorrect docs for HTTP::Status::
makholm opened this issue · comments
The documentation for HTTP::Status::status_message()
seems incorrect and/or misleading. it states that:
The status_message() function will translate status codes to human
readable strings. The string is the same as found in the constant
names above.
... giving the indication that e.g. status_message(404)
will return HTTP_NOT_FOUND
but it actually returns Not Found
.
It would be nice to have an easy way of turning a numeric code back to the constant name, but I assume the code work as intended and the documentation is just misleading...
@makholm , Lasse, you are right, the documentation is slightly misleading. Something easy to fix.
an easy way of turning a numeric code back to the constant name
Do you have a true use case for it, what would you want to do with the string representation of the constant; you can not compare the two, in your code you typically want to use the constant names, or the 'human readable' form from status_message
Oh, I can think of a use case... a code generator!!!
@makholm , Lasse, you are right, the documentation is slightly misleading. Something easy to fix.
an easy way of turning a numeric code back to the constant name
Do you have a true use case for it, what would you want to do with the string representation of the constant; you can not compare the two, in your code you typically want to use the constant names, or the 'human readable' form from
status_message
I just wanted to log the constant name as a more readable alternative to the numeric code in some integration tests against a REST service but I don't think it's a particularly good use case and probably not one that should drive a new feature...
You can probably roll your own, or copy/past from the code:
$message =~ s/I'm/I am/;
$message =~ tr/a-z \-/A-Z__/;
How about a PR where I
- update the doc to resolve @makholm's original concern
- add a
status_name()
function to map 305 to"HTTP_USE_PROXY"
, for example
?
status_constant_name
may be a better function name.
@neilb a PR would be great! I like the suggestion of status_constant_name
as well.
Closed via #182