X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=blobdiff_plain;f=lib%2FPackages%2FDoIndex.pm;h=064a18ad2aa4b386c336dccc3d01af144ca25a0e;hp=8ca34f5a0097a2a235be92465f0260a1441dce26;hb=01393b020237bbfa4571d41cc98899b4d25acd8b;hpb=ab47ae363dddbc35743572c62fae6350dcb7cf96 diff --git a/lib/Packages/DoIndex.pm b/lib/Packages/DoIndex.pm index 8ca34f5..064a18a 100644 --- a/lib/Packages/DoIndex.pm +++ b/lib/Packages/DoIndex.pm @@ -21,6 +21,15 @@ sub do_allpackages { return send_file( 'allpackages', @_ ); } +# no real need for more flexibility here, I think... +my %mime_types = ( + txt => 'text/plain', + 'txt.gz' => 'text/plain', + html => 'text/html', + ); +my %encoding = ( + 'txt.gz' => 'x-gzip', + ); sub send_file { my ($file, $params, $opts, $html_header) = @_; @@ -39,14 +48,17 @@ sub send_file { $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1; $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}}; # we don't have translated index pages for subsections yet - $opts->{lang} = 'en' if @{$opts->{subsection}}; + $opts->{lang} = 'en' if @{$opts->{subsection}} or $file eq 'allpackages'; $path .= "$file.$opts->{lang}.$opts->{format}"; unless (@Packages::CGI::fatal_errors) { my $buffer; if (open( INDEX, '<', "$wwwdir/$path" )) { - my $charset = get_charset( $opts->{lang} ); - print header( -charset => $charset ); + my %headers; + $headers{'-charset'} = get_charset( $opts->{lang} ); + $headers{'-type'} = $mime_types{$opts->{format}} || 'text/plain'; + $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}}; + print header( %headers ); binmode INDEX; while (read INDEX, $buffer, 4096) {