Skip to content

Commit 5228112

Browse files
committed
Tidy some files that have not been modified in the currently open Pull Requests as of 2024/11/3.
comm -23 <(git ls-files | sort) <(echo -n "8,16,23,25,35,93,99,117,122,141" | xargs -d, -I% sh -c 'git diff --name-only master...remotes/pr/%/head' | sort | uniq) | grep -E -e 'lib/' -e 't/.*\.t$' | xargs perltidy -b
1 parent d231eb5 commit 5228112

18 files changed

+783
-717
lines changed

lib/HTTP/Headers/Auth.pm

+69-69
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ our $VERSION = '7.01';
77

88
use HTTP::Headers;
99

10-
package
11-
HTTP::Headers;
10+
package HTTP::Headers;
1211

1312
BEGIN {
1413
# we provide a new (and better) implementations below
@@ -18,83 +17,84 @@ BEGIN {
1817

1918
require HTTP::Headers::Util;
2019

21-
sub _parse_authenticate
22-
{
20+
sub _parse_authenticate {
2321
my @ret;
24-
for (HTTP::Headers::Util::split_header_words(@_)) {
25-
if (!defined($_->[1])) {
26-
# this is a new auth scheme
27-
push(@ret, shift(@$_) => {});
28-
shift @$_;
29-
}
30-
if (@ret) {
31-
# this a new parameter pair for the last auth scheme
32-
while (@$_) {
33-
my $k = shift @$_;
34-
my $v = shift @$_;
35-
$ret[-1]{$k} = $v;
36-
}
37-
}
38-
else {
39-
# something wrong, parameter pair without any scheme seen
40-
# IGNORE
41-
}
22+
for ( HTTP::Headers::Util::split_header_words(@_) ) {
23+
if ( !defined( $_->[1] ) ) {
24+
25+
# this is a new auth scheme
26+
push( @ret, shift(@$_) => {} );
27+
shift @$_;
28+
}
29+
if (@ret) {
30+
31+
# this a new parameter pair for the last auth scheme
32+
while (@$_) {
33+
my $k = shift @$_;
34+
my $v = shift @$_;
35+
$ret[-1]{$k} = $v;
36+
}
37+
}
38+
else {
39+
# something wrong, parameter pair without any scheme seen
40+
# IGNORE
41+
}
4242
}
4343
@ret;
4444
}
4545

46-
sub _authenticate
47-
{
48-
my $self = shift;
46+
sub _authenticate {
47+
my $self = shift;
4948
my $header = shift;
50-
my @old = $self->_header($header);
49+
my @old = $self->_header($header);
5150
if (@_) {
52-
$self->remove_header($header);
53-
my @new = @_;
54-
while (@new) {
55-
my $a_scheme = shift(@new);
56-
if ($a_scheme =~ /\s/) {
57-
# assume complete valid value, pass it through
58-
$self->push_header($header, $a_scheme);
59-
}
60-
else {
61-
my @param;
62-
if (@new) {
63-
my $p = $new[0];
64-
if (ref($p) eq "ARRAY") {
65-
@param = @$p;
66-
shift(@new);
67-
}
68-
elsif (ref($p) eq "HASH") {
69-
@param = %$p;
70-
shift(@new);
71-
}
72-
}
73-
my $val = ucfirst(lc($a_scheme));
74-
if (@param) {
75-
my $sep = " ";
76-
while (@param) {
77-
my $k = shift @param;
78-
my $v = shift @param;
79-
if ($v =~ /[^0-9a-zA-Z]/ || lc($k) eq "realm") {
80-
# must quote the value
81-
$v =~ s,([\\\"]),\\$1,g;
82-
$v = qq("$v");
83-
}
84-
$val .= "$sep$k=$v";
85-
$sep = ", ";
86-
}
87-
}
88-
$self->push_header($header, $val);
89-
}
90-
}
51+
$self->remove_header($header);
52+
my @new = @_;
53+
while (@new) {
54+
my $a_scheme = shift(@new);
55+
if ( $a_scheme =~ /\s/ ) {
56+
57+
# assume complete valid value, pass it through
58+
$self->push_header( $header, $a_scheme );
59+
}
60+
else {
61+
my @param;
62+
if (@new) {
63+
my $p = $new[0];
64+
if ( ref($p) eq "ARRAY" ) {
65+
@param = @$p;
66+
shift(@new);
67+
}
68+
elsif ( ref($p) eq "HASH" ) {
69+
@param = %$p;
70+
shift(@new);
71+
}
72+
}
73+
my $val = ucfirst( lc($a_scheme) );
74+
if (@param) {
75+
my $sep = " ";
76+
while (@param) {
77+
my $k = shift @param;
78+
my $v = shift @param;
79+
if ( $v =~ /[^0-9a-zA-Z]/ || lc($k) eq "realm" ) {
80+
81+
# must quote the value
82+
$v =~ s,([\\\"]),\\$1,g;
83+
$v = qq("$v");
84+
}
85+
$val .= "$sep$k=$v";
86+
$sep = ", ";
87+
}
88+
}
89+
$self->push_header( $header, $val );
90+
}
91+
}
9192
}
9293
return unless defined wantarray;
93-
wantarray ? _parse_authenticate(@old) : join(", ", @old);
94+
wantarray ? _parse_authenticate(@old) : join( ", ", @old );
9495
}
9596
96-
97-
sub www_authenticate { shift->_authenticate("WWW-Authenticate", @_) }
98-
sub proxy_authenticate { shift->_authenticate("Proxy-Authenticate", @_) }
97+
sub www_authenticate { shift->_authenticate( "WWW-Authenticate", @_ ) }
98+
sub proxy_authenticate { shift->_authenticate( "Proxy-Authenticate", @_ ) }
9999
100100
1;

lib/HTTP/Headers/ETag.pm

+37-41
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,47 @@ our $VERSION = '7.01';
88
require HTTP::Date;
99

1010
require HTTP::Headers;
11-
package
12-
HTTP::Headers;
11+
package HTTP::Headers;
1312

14-
sub _etags
15-
{
16-
my $self = shift;
13+
sub _etags {
14+
my $self = shift;
1715
my $header = shift;
18-
my @old = _split_etag_list($self->_header($header));
16+
my @old = _split_etag_list( $self->_header($header) );
1917
if (@_) {
20-
$self->_header($header => join(", ", _split_etag_list(@_)));
18+
$self->_header( $header => join( ", ", _split_etag_list(@_) ) );
2119
}
22-
wantarray ? @old : join(", ", @old);
20+
wantarray ? @old : join( ", ", @old );
2321
}
2422

25-
sub etag { shift->_etags("ETag", @_); }
26-
sub if_match { shift->_etags("If-Match", @_); }
27-
sub if_none_match { shift->_etags("If-None-Match", @_); }
23+
sub etag { shift->_etags( "ETag", @_ ); }
24+
sub if_match { shift->_etags( "If-Match", @_ ); }
25+
sub if_none_match { shift->_etags( "If-None-Match", @_ ); }
2826

2927
sub if_range {
28+
3029
# Either a date or an entity-tag
3130
my $self = shift;
32-
my @old = $self->_header("If-Range");
31+
my @old = $self->_header("If-Range");
3332
if (@_) {
34-
my $new = shift;
35-
if (!defined $new) {
36-
$self->remove_header("If-Range");
37-
}
38-
elsif ($new =~ /^\d+$/) {
39-
$self->_date_header("If-Range", $new);
40-
}
41-
else {
42-
$self->_etags("If-Range", $new);
43-
}
33+
my $new = shift;
34+
if ( !defined $new ) {
35+
$self->remove_header("If-Range");
36+
}
37+
elsif ( $new =~ /^\d+$/ ) {
38+
$self->_date_header( "If-Range", $new );
39+
}
40+
else {
41+
$self->_etags( "If-Range", $new );
42+
}
4443
}
4544
return unless defined(wantarray);
4645
for (@old) {
47-
my $t = HTTP::Date::str2time($_);
48-
$_ = $t if $t;
46+
my $t = HTTP::Date::str2time($_);
47+
$_ = $t if $t;
4948
}
50-
wantarray ? @old : join(", ", @old);
49+
wantarray ? @old : join( ", ", @old );
5150
}
5251

53-
5452
# Split a list of entity tag values. The return value is a list
5553
# consisting of one element per entity tag. Suitable for parsing
5654
# headers like C<If-Match>, C<If-None-Match>. You might even want to
@@ -61,36 +59,34 @@ sub if_range {
6159
# weak = "W/"
6260
# opaque-tag = quoted-string
6361

64-
65-
sub _split_etag_list
66-
{
67-
my(@val) = @_;
62+
sub _split_etag_list {
63+
my (@val) = @_;
6864
my @res;
6965
for (@val) {
7066
while (length) {
7167
my $weak = "";
72-
$weak = "W/" if s,^\s*[wW]/,,;
68+
$weak = "W/" if s,^\s*[wW]/,,;
7369
my $etag = "";
74-
if (s/^\s*(\"[^\"\\]*(?:\\.[^\"\\]*)*\")//) {
75-
push(@res, "$weak$1");
70+
if (s/^\s*(\"[^\"\\]*(?:\\.[^\"\\]*)*\")//) {
71+
push( @res, "$weak$1" );
7672
}
7773
elsif (s/^\s*,//) {
78-
push(@res, qq(W/"")) if $weak;
74+
push( @res, qq(W/"") ) if $weak;
7975
}
8076
elsif (s/^\s*([^,\s]+)//) {
8177
$etag = $1;
82-
$etag =~ s/([\"\\])/\\$1/g;
83-
push(@res, qq($weak"$etag"));
78+
$etag =~ s/([\"\\])/\\$1/g;
79+
push( @res, qq($weak"$etag") );
8480
}
85-
elsif (s/^\s+// || !length) {
86-
push(@res, qq(W/"")) if $weak;
81+
elsif ( s/^\s+// || !length ) {
82+
push( @res, qq(W/"") ) if $weak;
8783
}
8884
else {
89-
die "This should not happen: '$_'";
85+
die "This should not happen: '$_'";
9086
}
9187
}
92-
}
93-
@res;
88+
}
89+
@res;
9490
}
9591

9692
1;

0 commit comments

Comments
 (0)