X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FTT%2FXHTML.pm;h=e256a0f3a26eae9f5ac306cdc0300bfe72a9a0ed;hb=06cf3efb1da299bac366b12870949662170b977d;hp=17bf1bfac71badb1c686f96e0cad84085c7fd8e8;hpb=b2454602d2cb3abd667d10f746840180a1a5e9ca;p=catagits%2FCatalyst-View-ContentNegotiation-XHTML.git diff --git a/lib/Catalyst/View/TT/XHTML.pm b/lib/Catalyst/View/TT/XHTML.pm index 17bf1bf..e256a0f 100644 --- a/lib/Catalyst/View/TT/XHTML.pm +++ b/lib/Catalyst/View/TT/XHTML.pm @@ -1,19 +1,28 @@ package Catalyst::View::TT::XHTML; use strict; use warnings; +use HTTP::Negotiate qw(choose); use base qw/Catalyst::View::TT/; -our $VERSION = '1.000'; +our $VERSION = '1.001'; + +our $variants = [ + [qw| xhtml 1.000 application/xhtml+xml |], + [qw| html 0.001 text/html |], +]; sub process { my $self = shift; my ($c) = @_; - $self->next::method(@_); - my $accept = $c->request->header('Accept'); - if ( $accept && $accept =~ m|application/xhtml\+xml|) { - $c->response->headers->{'content-type'} =~ s|text/html|application/xhtml+xml|; + my $return = $self->next::method(@_); + + if ($c->request->header('Accept') && $c->response->headers->{'content-type'} =~ m|text/html|) { + my $var = choose($variants, $c->request->headers); + if ($var eq 'xhtml') { + $c->response->headers->{'content-type'} =~ s|text/html|application/xhtml+xml|; + } } - return 1; + return $return; } 1;