Changeset 634

Show
Ignore:
Timestamp:
05/03/02 22:28:35
Author:
miyagawa
Message:

0.02 release

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Apache-GuessCharset/trunk/Changes

    r627 r634  
    11Revision history for Perl extension Apache::GuessCharset 
     2 
     30.02  Fri May  3 22:27:43 JST 2002 
     4        - uses $r->finfo and fixed some style issue 
     5          (Thanks to Geoffrey Young <geoff@modperlcookbook.org>) 
     6        - CPAN release 
    27 
    380.01  Tue Apr 30 14:33:20 2002 
  • Apache-GuessCharset/trunk/lib/Apache/GuessCharset.pm

    r627 r634  
    22 
    33use strict; 
    4 our $VERSION = 0.01; 
    5  
     4our $VERSION = 0.02; 
    65 
    76use Apache::Constants; 
     
    3231sub handler { 
    3332    my $r = shift; 
    34     return DECLINED unless $r->content_type eq 'text/html'; 
    35     my $filename = $r->filename; 
    36     -e $filename or return DECLINED; 
    37     my $chunk = read_chunk($r, $filename); 
     33    return DECLINED unless $r->content_type eq 'text/html'; # XXX: should it be text/*? 
     34    return DECLINED if !-e $r->finfo or -d _; 
     35    my $chunk = read_chunk($r) or return DECLINED; 
    3836 
    3937    my @suspects = $r->dir_config->get('GuessCharsetSuspects'); 
    4038    my $enc  = guess_encoding($chunk, @suspects); 
    41     ref $enc or        return DECLINED
     39    return DECLINED unless ref $enc
    4240 
    4341    my $iana    = iana_charset_name($enc->name); 
     
    4846 
    4947sub read_chunk { 
    50     my($r, $file) = @_
    51     my $fh   = Apache::File->new($file) or die "$file: $!"
     48    my $r  = shift
     49    my $fh = Apache::File->new($r->filename) or return
    5250    my $buffer_size = $r->dir_config('GuessCharsetBufferSize') || 512; 
    5351    read $fh, my($chunk), $buffer_size; 
    54     $fh->close; 
    5552    return $chunk; 
    5653} 
     
    6562=head1 SYNOPSIS 
    6663 
    67   PerlModule Apache::GuessCharset 
    6864  SetHandler perl-script 
    69   PerlFixupHandler Apache::GuessCharset 
     65  PerlFixupHandler +Apache::GuessCharset 
    7066 
    7167  # how many bytes to read for guessing (default 512)