[Jifty-commit] r3210 - in jifty/trunk/lib/Jifty/View: Mason
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon May 7 17:27:40 EDT 2007
Author: ruz
Date: Mon May 7 17:27:38 2007
New Revision: 3210
Modified:
jifty/trunk/lib/Jifty/View/Declare/Handler.pm
jifty/trunk/lib/Jifty/View/Mason/Handler.pm
Log:
* FCGI.pm ties our streams and its implementation doesn't have support
for setting IO layers with binmode, but we can do the same using
Encode::encode. We just turn on raw mode on STDOUT and convert to
octets ourself using Encode.pm and charset definition from the content
type field.
Modified: jifty/trunk/lib/Jifty/View/Declare/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/View/Declare/Handler.pm Mon May 7 17:27:38 2007
@@ -83,18 +83,12 @@
Jifty->handler->apache->send_http_header;
}
+ binmode *STDOUT;
if ( my ($enc) = $r->content_type =~ /charset=([\w-]+)$/ ) {
- if ( lc($enc) =~ /utf-?8/) {
- binmode *STDOUT, ":utf8" or die "couldn't set layers: $!";
- }
- else {
- binmode *STDOUT, ":encoding($enc)" or die "couldn't set layers: $!";
- }
+ print STDOUT Encode::encode($enc, $content);
} else {
- binmode *STDOUT or die "couldn't set layers: $!";
+ print STDOUT $content;
}
-
- print STDOUT $content;
return undef;
}
Modified: jifty/trunk/lib/Jifty/View/Mason/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Mason/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/View/Mason/Handler.pm Mon May 7 17:27:38 2007
@@ -131,17 +131,6 @@
$r->content_type || $r->content_type('text/html; charset=utf-8'); # Set up a default
- if ( my ($enc) = $r->content_type =~ /charset=([\w-]+)$/ ) {
- if ( lc($enc) =~ /utf-?8/ ) {
- binmode *STDOUT, ":utf8";
- }
- else {
- binmode *STDOUT, ":encoding($enc)";
- }
- } else {
- binmode *STDOUT;
- }
-
unless ( $r->http_header_sent or not $m->auto_send_headers ) {
$r->send_http_header();
}
@@ -150,7 +139,12 @@
# wouldn't have to keep checking whether headers have been
# sent and what the $r->method is. That would require
# additions to the Request interface, though.
- print STDOUT grep {defined} @_;
+ binmode *STDOUT;
+ if ( my ($enc) = $r->content_type =~ /charset=([\w-]+)$/ ) {
+ print STDOUT map Encode::encode($enc, $_), grep {defined} @_;
+ } else {
+ print STDOUT grep {defined} @_;
+ }
}
More information about the Jifty-commit
mailing list