Add support for printing more headers

This commit is contained in:
Ilia Ross
2025-05-04 13:18:08 +03:00
parent c5b0e4c7ff
commit 9a48d874e2

View File

@@ -1066,7 +1066,7 @@ else {
}
}
=head2 PrintHeader(charset, [mime-type])
=head2 PrintHeader([charset], [mime-type], [headers])
Outputs the HTTP headers for an HTML page. The optional charset parameter
can be used to set a character set. Normally this function is not called
@@ -1075,7 +1075,7 @@ directly, but is rather called by ui_print_header or header.
=cut
sub PrintHeader
{
my ($cs, $mt) = @_;
my ($cs, $mt, $headers) = @_;
$mt ||= "text/html";
if ($ENV{'SSL_HSTS'} == 1 && uc($ENV{'HTTPS'}) eq "ON") {
print "Strict-Transport-Security: max-age=31536000;\n";
@@ -1094,6 +1094,12 @@ if ($gconfig{'extra_headers'}) {
print $l."\n";
}
}
if ($headers) {
foreach my $h (@{$headers}) {
my ($name, $value) = @{$h};
print "$name: $value\n";
}
}
if (!$gconfig{'no_frame_options'}) {
print "X-Frame-Options: SAMEORIGIN\n";
}