[Jifty-commit] r2421 - in jifty/branches/template-declare: . lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Dec 22 20:53:46 EST 2006


Author: jesse
Date: Fri Dec 22 20:53:46 2006
New Revision: 2421

Modified:
   jifty/branches/template-declare/   (props changed)
   jifty/branches/template-declare/lib/Jifty/Server.pm
   jifty/branches/template-declare/lib/Jifty/View/Declare/Handler.pm

Log:
 r46403 at pinglin:  jesse | 2006-12-22 17:53:37 -0800
 * better handling of printing http response codes


Modified: jifty/branches/template-declare/lib/Jifty/Server.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Server.pm	(original)
+++ jifty/branches/template-declare/lib/Jifty/Server.pm	Fri Dec 22 20:53:46 2006
@@ -36,6 +36,11 @@
 
 =cut
 
+sub _send_http_status {
+      print STDOUT "HTTP/1.0 ".  (Jifty->handler->apache->{headers_out}->{'Status'} || '200 Jifty OK') .  "\n";
+};
+
+
 sub new {
     my $class = shift;
     my $self  = {};
@@ -44,15 +49,8 @@
     $self->recording_on if $ENV{'JIFTY_RECORD'};
 
     use Hook::LexWrap;
-    wrap 'Jifty::View::Declare::Handler::send_http_header', pre => sub {
-        print STDOUT "HTTP/1.0 ".  (Jifty->handler->apache->{headers_out}->{'Status'} || '200 Jifty OK') .  "\n";
-    };
-
-    wrap 'HTML::Mason::FakeApache::send_http_header', pre => sub {
-        my $r = shift;
-        my $status = $r->header_out('Status') || '200 Jifty OK';
-        print STDOUT "HTTP/1.0 $status\n";
-    };
+    wrap 'HTML::Mason::FakeApache::send_http_header', pre => \&_send_http_status;
+    
 
     return ($self);
 

Modified: jifty/branches/template-declare/lib/Jifty/View/Declare/Handler.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/View/Declare/Handler.pm	(original)
+++ jifty/branches/template-declare/lib/Jifty/View/Declare/Handler.pm	Fri Dec 22 20:53:46 2006
@@ -29,8 +29,8 @@
     no warnings qw/redefine utf8/;
     local *Jifty::Web::out = sub {
         shift;    # Turn the method into a function
-        unless ( Jifty->handler->stash->{http_header_sent} ) {
-            $self->send_http_header();
+        unless ( Jifty->handler->apache->http_header_sent ) {
+            Jifty->handler->apache->send_http_header();
         }
 
         local $Template::Declare::Tags::BUFFER = '';
@@ -41,23 +41,6 @@
     return undef;
 }
 
-sub send_http_header {
-    my $self = shift;
-    my $r = Jifty->handler->apache;
-    $r->content_type
-        || $r->content_type('text/html; charset=utf-8');    # Set up a default
-    if ( $r->content_type =~ /charset=([\w-]+)$/ ) {
-        my $enc = $1;
-        binmode *STDOUT,
-            ( ( lc($enc) =~ /utf-?8/ ) ? ":utf8" : "encoding($enc)" );
-    }
-
-    #HTML::Mason::FakeApache's send_http_header uses "print STDOUT"
-    # this reimplements that.
-    print STDOUT $r->http_header;
-    Jifty->handler->stash->{http_header_sent} = 1;
-}
-
 sub resolve_template { my $pkg =shift;  return Template::Declare->resolve_template(@_);}
 
 1;


More information about the Jifty-commit mailing list