File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ Revision history for HTTP-Message
33{{$NEXT}}
44 - Allow for file ownership conflicts with Docker and GitHub Actions
55 (GH#193) (Olaf Alders)
6+ - Add the 'status_code' function for getting all status codes as hash
7+ (GH#194) (Dai Okabayashi)
68
796.44 2022-10-26 20:49:00Z
810 - Made the Clone module a hard requirement, so we don't have to
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ our $VERSION = '6.45';
88use Exporter 5.57 ' import' ;
99
1010our @EXPORT = qw( is_info is_success is_redirect is_error status_message) ;
11- our @EXPORT_OK = qw( is_client_error is_server_error is_cacheable_by_default status_constant_name) ;
11+ our @EXPORT_OK = qw( is_client_error is_server_error is_cacheable_by_default status_constant_name status_codes ) ;
1212
1313# Note also addition of mnemonics to @EXPORT below
1414
@@ -169,6 +169,8 @@ sub is_cacheable_by_default ($) { $_[0] && ( $_[0] == 200 # OK
169169 );
170170}
171171
172+ sub status_codes { %StatusCode ; }
173+
1721741;
173175
174176
@@ -343,6 +345,12 @@ Section 6.1. Overview of Status Codes|https://tools.ietf.org/html/rfc7231#sectio
343345
344346This function is B<not > exported by default.
345347
348+ =item status_codes
349+
350+ Returns a hash mapping numerical HTTP status code (e.g. 200) to text status messages (e.g. "OK")
351+
352+ This function is B<not > exported by default.
353+
346354=back
347355
348356=head1 SEE ALSO
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ use strict;
22use warnings;
33
44use Test::More;
5- plan tests => 52 ;
5+ plan tests => 53 ;
66
7- use HTTP::Status qw( :constants :is status_message status_constant_name) ;
7+ use HTTP::Status qw( :constants :is status_message status_constant_name status_codes ) ;
88
99is(HTTP_OK, 200);
1010
@@ -56,3 +56,6 @@ ok(!is_cacheable_by_default($_),
5656is(status_constant_name(HTTP_OK), " HTTP_OK" );
5757is(status_constant_name(404), " HTTP_NOT_FOUND" );
5858is(status_constant_name(999), undef );
59+
60+ my %status_codes = status_codes();
61+ is($status_codes {200 }, status_message(200));
You can’t perform that action at this time.
0 commit comments