FU: Improve merging of "Vary" response headers + debug header listing
This commit is contained in:
parent
f2294a709a
commit
1594006739
2 changed files with 10 additions and 8 deletions
7
FU.pm
7
FU.pm
|
|
@ -863,14 +863,12 @@ sub _finalize {
|
||||||
$r->{resbody} = '';
|
$r->{resbody} = '';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
my @vary = ref $r->{reshdr}{vary} eq 'ARRAY' ? $r->{reshdr}{vary}->@* : defined $r->{reshdr}{vary} ? ($r->{reshdr}{vary}) : ();
|
||||||
if (($hasgzip || $hasbrotli) && length($r->{resbody}) > 256
|
if (($hasgzip || $hasbrotli) && length($r->{resbody}) > 256
|
||||||
&& !defined $r->{reshdr}{'content-encoding'}
|
&& !defined $r->{reshdr}{'content-encoding'}
|
||||||
&& FU::compress_mimes->{$r->{reshdr}{'content-type'}}
|
&& FU::compress_mimes->{$r->{reshdr}{'content-type'}}
|
||||||
) {
|
) {
|
||||||
|
push @vary, 'accept-encoding';
|
||||||
$r->{reshdr}{'vary'} = ($r->{reshdr}{'vary'} ? $r->{reshdr}{'vary'}.', ' : '').'accept-encoding'
|
|
||||||
if ($r->{reshdr}{'vary'}||'') !~ /accept-encoding/i;
|
|
||||||
|
|
||||||
if ($hasbrotli && ($r->{hdr}{'accept-encoding'}||'') =~ /\bbr\b/) {
|
if ($hasbrotli && ($r->{hdr}{'accept-encoding'}||'') =~ /\bbr\b/) {
|
||||||
$r->{resbody} = FU::Util::brotli_compress(6, $r->{resbody});
|
$r->{resbody} = FU::Util::brotli_compress(6, $r->{resbody});
|
||||||
$r->{reshdr}{'content-encoding'} = 'br';
|
$r->{reshdr}{'content-encoding'} = 'br';
|
||||||
|
|
@ -880,6 +878,7 @@ sub _finalize {
|
||||||
$r->{reshdr}{'content-encoding'} = 'gzip';
|
$r->{reshdr}{'content-encoding'} = 'gzip';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$r->{reshdr}{vary} = @vary ? join ', ', @vary : undef;
|
||||||
$r->{reshdr}{'content-length'} = length $r->{resbody};
|
$r->{reshdr}{'content-length'} = length $r->{resbody};
|
||||||
$r->{resbody} = '' if (fu->method//'') eq 'HEAD';
|
$r->{resbody} = '' if (fu->method//'') eq 'HEAD';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,10 +75,13 @@ my @tabs = (
|
||||||
};
|
};
|
||||||
h2_ 'Headers';
|
h2_ 'Headers';
|
||||||
table_ sub {
|
table_ sub {
|
||||||
tr_ sub {
|
for my $k (sort keys $r->{reshdr}->%*) {
|
||||||
td_ $_;
|
my $v = $r->{reshdr}{$k};
|
||||||
td_ $r->{reshdr}{$_};
|
tr_ sub {
|
||||||
} for sort keys $r->{reshdr}->%*;
|
td_ $k;
|
||||||
|
td_ $_;
|
||||||
|
} for !defined $v ? () : ref $v ? @$v : ($v);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
('Response')
|
('Response')
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue