[Rt-commit] r2488 - in rt/branches/3.4-RELEASE: .
lib/RT/Interface/Web
jesse at bestpractical.com
jesse at bestpractical.com
Tue Mar 22 10:16:56 EST 2005
Author: jesse
Date: Tue Mar 22 10:16:55 2005
New Revision: 2488
Modified:
rt/branches/3.4-RELEASE/ (props changed)
rt/branches/3.4-RELEASE/lib/RT/Interface/Web/Standalone.pm
Log:
r9555 at hualien: jesse | 2005-03-22 22:15:24 +0800
* Properly set binmode for the standalone_httpd server. This makes
UTF8 text that could be misinterpreted as Latin1 behave correctly.
Modified: rt/branches/3.4-RELEASE/lib/RT/Interface/Web/Standalone.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Interface/Web/Standalone.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Interface/Web/Standalone.pm Tue Mar 22 10:16:55 2005
@@ -6,14 +6,44 @@
use RT::Interface::Web;
sub new_handler {
- RT::Interface::Web::Handler->new(@RT::MasonParameters);
+ my $m;
+ $m= RT::Interface::Web::Handler->new(@RT::MasonParameters,
+ # Override mason's default output method so
+ # we can change the binmode to our encoding if
+ # we happen to be handed character data instead
+ # of binary data.
+ #
+ # Cloned from HTML::Mason::CGIHandler
+ out_method =>
+ sub {
+ my $m = HTML::Mason::Request->instance;
+ my $r = $m->cgi_request;
+ # Send headers if they have not been sent by us or by user.
+ # We use instance here because if we store $request we get a
+ # circular reference and a big memory leak.
+ unless ($r->http_header_sent) {
+ $r->send_http_header();
+ }
+ {
+ if ($r->content_type =~ /charset=([\w-]+)$/ ) {
+ my $enc = $1;
+ binmode *STDOUT, ":encoding($enc)";
+ }
+ # We could perhaps install a new, faster out_method here that
+ # 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} @_;
+ }
+ }
+ );
+ return ($m);
}
sub handle_request {
my $self = shift;
my $cgi = shift;
-
$self->SUPER::handle_request($cgi);
$RT::Logger->crit($@) if ($@);
More information about the Rt-commit
mailing list