Changeset 642

Show
Ignore:
Timestamp:
05/11/02 14:24:23
Author:
miyagawa
Message:

0.03 release

Files:

Legend:

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

    r634 r642  
    11Revision history for Perl extension Apache::GuessCharset 
     2 
     30.03  Sat May 11 13:31:31 JST 2002 
     4        * handles any text/* requests without charset attribute 
     5        * charset attribute is now lowercased 
     6        - returns DECLINED if not in main request 
     7        - added mock test code 
    28 
    390.02  Fri May  3 22:27:43 JST 2002 
  • Apache-GuessCharset/trunk/MANIFEST

    r627 r642  
    55lib/Apache/GuessCharset.pm 
    66t/00_compile.t 
     7t/01_guess.t 
     8t/sjis.html 
  • Apache-GuessCharset/trunk/lib/Apache/GuessCharset.pm

    r634 r642  
    22 
    33use strict; 
    4 our $VERSION = 0.02; 
     4our $VERSION = 0.03; 
     5our $DEBUG   = 0; 
    56 
    67use Apache::Constants; 
     
    3132sub handler { 
    3233    my $r = shift; 
    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; 
     34    return DECLINED if 
     35        ! $r->is_main                  or 
     36        $r->content_type !~ m@^text/@  or 
     37        $r->content_type =~ /charset=/ or 
     38        ! -e $r->finfo                 or 
     39        -d _                           or 
     40        !(my $chunk = read_chunk($r)); 
    3641 
    3742    my @suspects = $r->dir_config->get('GuessCharsetSuspects'); 
    3843    my $enc  = guess_encoding($chunk, @suspects); 
    39     return DECLINED unless ref $enc; 
     44    unless (ref $enc) { 
     45        warn "Couldn't guess encoding: $enc" if $DEBUG; 
     46        return DECLINED; 
     47    } 
    4048 
    4149    my $iana    = iana_charset_name($enc->name); 
    42     my $charset = $Prefered_MIME{$iana} || $iana; 
    43     $r->content_type("text/html; charset=$charset"); 
     50    my $charset = lc($Prefered_MIME{$iana} || $iana); # lowercased 
     51    warn "Guessed: $charset" if $DEBUG; 
     52    $r->content_type($r->content_type . "; charset=$charset"); 
    4453    return OK; 
    4554} 
     
    7584=head1 DESCRIPTION 
    7685 
    77 Apache::GuessCharset is an Apache handler which adds HTTP charset 
    78 attribute by automaticaly guessing file' encodings via Encode::Guess. 
     86Apache::GuessCharset is an Apache fix-up handler which adds HTTP 
     87charset attribute by automaticaly guessing text files' encodings via 
     88Encode::Guess. 
    7989 
    8090=head1 CONFIGURATION