Mercurial > pub > Impl
comparison Lib/IMPL/Web/Application.pm @ 130:06a34c197b05
Added support for utf-8 and old versions of CGI module
author | wizard |
---|---|
date | Wed, 16 Jun 2010 01:50:56 +0400 |
parents | e4f15cbc3f1a |
children | c5bc900eefd3 |
comparison
equal
deleted
inserted
replaced
129:e4f15cbc3f1a | 130:06a34c197b05 |
---|---|
73 | 73 |
74 sub defaultFetchRequest { | 74 sub defaultFetchRequest { |
75 my ($this) = @_; | 75 my ($this) = @_; |
76 return undef if $hasFetched; | 76 return undef if $hasFetched; |
77 $hasFetched = 1; | 77 $hasFetched = 1; |
78 my $query = CGI->new(); | 78 my $query = CGIWrapper->new(); |
79 $query->charset($this->responseCharset); | 79 $query->charset($this->responseCharset); |
80 return $query; | 80 return $query; |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
90 $action->response->status(500); | 90 $action->response->status(500); |
91 my $hout = $action->response->streamBody; | 91 my $hout = $action->response->streamBody; |
92 print $hout $e; | 92 print $hout $e; |
93 $action->response->Complete(); | 93 $action->response->Complete(); |
94 } | 94 } |
95 } | |
96 | |
97 package CGIWrapper; | |
98 use base qw(CGI); | |
99 | |
100 use Encode; | |
101 | |
102 sub param { | |
103 my $this = shift; | |
104 | |
105 if (wantarray) { | |
106 my @result = $this->SUPER::param(@_); | |
107 | |
108 return map Encode::is_utf8($_) ? $_ : Encode::decode($this->charset,$_,Encode::LEAVE_SRC), @result; | |
109 } else { | |
110 my $result = $this->SUPER::param(@_); | |
111 | |
112 return Encode::is_utf8($result) ? $result : Encode::decode($this->charset,$result,Encode::LEAVE_SRC); | |
113 } | |
114 | |
95 } | 115 } |
96 | 116 |
97 1; | 117 1; |
98 | 118 |
99 __END__ | 119 __END__ |