Skip to content

Commit 202d3b2

Browse files
Grinnzoalders
authored andcommitted
clean up repetitive backcompat code
1 parent 8498608 commit 202d3b2

File tree

2 files changed

+15
-28
lines changed

2 files changed

+15
-28
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Revision history for HTTP-Message
22

33
{{$NEXT}}
4+
- Clean up backcompat code (GH#148) (Dan Book)
45

56
6.26 2020-09-10 02:34:25Z
67
- Update comment which explains in which RFC 451 is defined (GH#143) (Olaf

lib/HTTP/Status.pm

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -117,35 +117,21 @@ die if $@;
117117
*RC_MOVED_TEMPORARILY = \&RC_FOUND; # 302 was renamed in the standard
118118
push(@EXPORT, "RC_MOVED_TEMPORARILY");
119119

120-
*RC_REQUEST_ENTITY_TOO_LARGE = \&RC_PAYLOAD_TOO_LARGE;
121-
push(@EXPORT, "RC_REQUEST_ENTITY_TOO_LARGE");
122-
123-
*RC_REQUEST_URI_TOO_LARGE = \&RC_URI_TOO_LONG;
124-
push(@EXPORT, "RC_REQUEST_URI_TOO_LARGE");
125-
126-
*RC_REQUEST_RANGE_NOT_SATISFIABLE = \&RC_RANGE_NOT_SATISFIABLE;
127-
push(@EXPORT, "RC_REQUEST_RANGE_NOT_SATISFIABLE");
128-
129-
*RC_NO_CODE = \&RC_TOO_EARLY;
130-
push(@EXPORT, "RC_NO_CODE");
131-
132-
*RC_UNORDERED_COLLECTION = \&RC_TOO_EARLY;
133-
push(@EXPORT, "RC_UNORDERED_COLLECTION");
134-
135-
*HTTP_REQUEST_ENTITY_TOO_LARGE = \&HTTP_PAYLOAD_TOO_LARGE;
136-
push(@EXPORT_OK, "HTTP_REQUEST_ENTITY_TOO_LARGE");
137-
138-
*HTTP_REQUEST_URI_TOO_LARGE = \&HTTP_URI_TOO_LONG;
139-
push(@EXPORT_OK, "HTTP_REQUEST_URI_TOO_LARGE");
140-
141-
*HTTP_REQUEST_RANGE_NOT_SATISFIABLE = \&HTTP_RANGE_NOT_SATISFIABLE;
142-
push(@EXPORT_OK, "HTTP_REQUEST_RANGE_NOT_SATISFIABLE");
143-
144-
*HTTP_NO_CODE = \&HTTP_TOO_EARLY;
145-
push(@EXPORT_OK, "HTTP_NO_CODE");
120+
my %compat = (
121+
REQUEST_ENTITY_TOO_LARGE => \&HTTP_PAYLOAD_TOO_LARGE,
122+
REQUEST_URI_TOO_LARGE => \&HTTP_URI_TOO_LONG,
123+
REQUEST_RANGE_NOT_SATISFIABLE => \&HTTP_RANGE_NOT_SATISFIABLE,
124+
NO_CODE => \&HTTP_TOO_EARLY,
125+
UNORDERED_COLLECTION => \&HTTP_TOO_EARLY,
126+
);
146127

147-
*HTTP_UNORDERED_COLLECTION = \&HTTP_TOO_EARLY;
148-
push(@EXPORT_OK, "HTTP_UNORDERED_COLLECTION");
128+
foreach my $name (keys %compat) {
129+
push(@EXPORT, "RC_$name");
130+
push(@EXPORT_OK, "HTTP_$name");
131+
no strict 'refs';
132+
*{"RC_$name"} = $compat{$name};
133+
*{"HTTP_$name"} = $compat{$name};
134+
}
149135

150136
our %EXPORT_TAGS = (
151137
constants => [grep /^HTTP_/, @EXPORT_OK],

0 commit comments

Comments
 (0)