annotate Lib/IMPL/Web/Application/Response.pm @ 203:68a59c3358ff

Implemented templates selection mechanism
author sergey
date Wed, 25 Apr 2012 18:06:11 +0400
parents 4d0e1962161c
children f534a60d5b01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
59
0f3e369553bd Rewritten property implementation (probably become slower but more flexible)
wizard
parents: 58
diff changeset
1 package IMPL::Web::Application::Response;
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
2 use strict;
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
3
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 97
diff changeset
4 use parent qw(IMPL::Object IMPL::Object::Autofill);
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
5
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
6 require IMPL::Exception;
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
7 require CGI;
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
8 require CGI::Cookie;
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
9
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
10 use Carp;
63
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 59
diff changeset
11 use Encode;
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
12 use IMPL::Class::Property;
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
13
63
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 59
diff changeset
14 #todo: add binary method to set a binary encoding, set it automatic when type isn't a text
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 59
diff changeset
15
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
16 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
17 # автозаполнение буде происходить в порядке объявления
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
18 public property query => prop_get | owner_set; # cgi query
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
19 public property status => prop_all, { validator => \&_checkHeaderPrinted };
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
20 public property contentType => prop_all, { validator => \&_checkHeaderPrinted }; # String
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
21 public property charset => { get => \&_charset, set => \&_charset }, { validator => \&_checkHeaderPrinted };
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 public property expires => prop_all, { validator => \&_checkHeaderPrinted };
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
23 public property cookies => prop_all, { validator => \&_checkHeaderPrinted }; # Hash
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
24
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
25 public property buffered => prop_all, { validator => \&_canChangeBuffer }; # Boolean
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
26 public property streamOut => prop_get | owner_set; # stream
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
27 public property streamBody => {get => \&getStreamBody }; # stream
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28 public property isHeaderPrinted => prop_get | owner_set; # Boolean
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
29
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
30 private property _bufferBody => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
31 private property _streamBody => prop_all;
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
32 }
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
33
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
34 __PACKAGE__->PassThroughArgs;
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
35
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
36 our %CTOR = (
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
37 'IMPL::Object::Autofill' => sub {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
38 my %args = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
39
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
40 $args{query} = CGI->new($args{query} || {});
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
41
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
42 %args;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
43 }
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
44 );
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
45
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
46 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
47 my ($this,%args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
48
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
49 if (lc $this->streamOut eq 'memory') {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
50 my $dummy = '';
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
51 open my $hout, '>:encoding(utf8)', \$dummy or die new IMPL::Exception("Failed to create memory stream",$!);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
52 $this->streamOut($hout);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
53 } elsif (not $this->streamOut) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
54 $this->streamOut(*STDOUT);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
55 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
56 die new IMPL::InvalidArgumentException("Invalid parameter value",$this->streamOut);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
57 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
58
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
59 $this->buffered(1) unless defined $this->buffered;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
60 binmode $this->streamOut, ":encoding(".$this->charset.")";
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
61 }
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
62
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
63 sub _checkHeaderPrinted {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
64 my ($this,$value) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
65
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
66 die new IMPL::InvalidOperationException() if $this->isHeaderPrinted;
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
67 }
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
68
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
69 sub _canChangeBuffer {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
70 my ($this,$value) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
71
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
72 die new IMPL::InvalidOperationException() if $this->isHeaderPrinted or $this->_streamBody;
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
73 }
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
74
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
75 sub _charset {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
76 my $this = shift;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
77
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
78 if (@_) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
79 my $charset = $this->query->charset(@_);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
80
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
81 my $hout = $this->streamOut;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
82
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
83 binmode $hout;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
84 binmode $hout, ":encoding($charset)";
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
85
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
86 return $charset;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
87 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
88 return $this->query->charset;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
89 }
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
90 }
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
91
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
92 sub _PrintHeader {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
93 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
94
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
95 unless ($this->isHeaderPrinted) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
96 $this->isHeaderPrinted(1);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
97
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
98 my %opt;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
99
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
100 $opt{-type} = $this->contentType if $this->contentType;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
101 $opt{-status} = $this->status if $this->status;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
102 $opt{-expires} = $this->expires if $this->expires;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
103
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
104 my $refCookies = $this->cookies;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
105 $opt{-cookie} = [map _createCookie($_,$refCookies->{$_}), keys %$refCookies] if $refCookies;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
106
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
107 my $hOut = $this->streamOut;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
108
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
109 print $hOut $this->query->header(
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
110 %opt
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
111 );
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
112 }
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
113 }
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
114
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents: 95
diff changeset
115 sub _createCookie {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
116 return UNIVERSAL::isa($_[1], 'CGI::Cookie') ? $_[1] : CGI::Cookie->new(-name => $_[0], -value => $_[1] );
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents: 95
diff changeset
117 }
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents: 95
diff changeset
118
95
67eb8eaec3d4 Added a security authority property to the Context and Security classes
wizard
parents: 67
diff changeset
119 sub setCookie {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
120 my ($this,$name,$value) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
121
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
122 unless ($this->cookies) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
123 $this->cookies({$name,$value});
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
124 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
125 $this->_checkHeaderPrinted();
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
126 $this->cookies->{$name} = $value;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
127 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
128 return $value;
95
67eb8eaec3d4 Added a security authority property to the Context and Security classes
wizard
parents: 67
diff changeset
129 }
67eb8eaec3d4 Added a security authority property to the Context and Security classes
wizard
parents: 67
diff changeset
130
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
131 sub getStreamBody {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
132 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
133
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
134 return undef unless $this->streamOut;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
135
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
136 unless ($this->_streamBody) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
137 if ($this->buffered) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
138 my $buffer = "";
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
139
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
140 $this->_bufferBody(\$buffer);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
141
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
142 open my $hBody, ">:encoding(utf-8)", \$buffer or die new IMPL::Exception("Failed to create buffer",$!);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
143
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
144 Encode::_utf8_on($buffer);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
145
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
146 $this->_streamBody($hBody);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
147 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
148 $this->_PrintHeader();
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
149 $this->_streamBody($this->streamOut);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
150 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
151 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
152
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
153 return $this->_streamBody;
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
154 }
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
155
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
156 sub Complete {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
157 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
158
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
159 return 0 unless $this->streamOut;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
160
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
161 my $hOut = $this->streamOut;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
162
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
163 $this->_PrintHeader();
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents: 95
diff changeset
164
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
165 close $this->_streamBody();
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
166
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
167 if ($this->buffered) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
168 print $hOut ${$this->_bufferBody};
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
169 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
170
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
171 $this->_bufferBody(undef);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
172 $this->streamOut(undef);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
173
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
174 return 1;
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
175 }
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
176
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
177 sub Discard {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
178 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
179
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
180 carp "Discarding sent response" if $this->isHeaderPrinted;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
181
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
182 $this->_streamBody(undef);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
183 $this->_bufferBody(undef);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
184 $this->streamOut(undef);
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
185 }
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
186
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
187 1;
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
188
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
189 __END__
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
190
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
191 =pod
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
192
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
193 =head1 NAME
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
194
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
195 C<IMPL::Web::Application::Response> - Ответ веб сервера непосредственно клиенту.
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
196
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
197 =head1 DESCRIPTION
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
198
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
199 C<[Infrastructure]>
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
200
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
201 Позволяет сформировать основные свойства заголовка и тело ответа.
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
202
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
203 Создается объектом C<IMPL::Web::Application::Action> в процессе обработки запроса.
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
204
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
205 Может использоваться обработчиками C<IMPL::Web::QueryHandler> в процессе выполнения запроса.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
206
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
207 Объект позволяет буфферизировать вывод в тело ответа, что позволяет отменить или изменить
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
208 ответ в последний момент. Свойство C< isHeaderPrinted > используется для определения факта
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
209 отправлки данных клиенту.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
210
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
211 =head1 PROPERTIES
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
212
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
213 =head2 HTTP Header
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
214
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
215 Свойства отвечающие за заголовок HTTP ответа. Эти своства могут быть изменены до тех пор пока
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
216 не будет отправлен заголовок. В противном случае выдается исключение C< IMPL::InvalidOperationException >.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
217
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
218 =over
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
219
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
220 =item C< [get] query >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
221
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
222 CGI запрос, который используется для вывода данных, заголовка и пр. Существует всегда.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
223
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
224 =item C< [get,set] status >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
225
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
226 Код ошибки HTTP. Например, '200 OK'. По умолчанию не установлен, при отправке клиенту бедт отправлен '200 ОК'.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
227
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
228 =item C< [get,set] contentType >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
229
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
230 Тип MIME. По умолчанию не установлен, подразумивается 'text/html'.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
231
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
232 =item C< [get,set] charset >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
233
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
234 Кодировка, синоним свойства query->charset.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
235
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
236 =item C< [get,set] expires >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
237
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
238 Определяет время жизни контента, например '+10m'. По умолчанию не задано и не передается.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
239
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
240 =item C< [get,set] cookies >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
241
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
242 Хеш массив с cookies, например C< { cart => ['foo','bar'], display => 'list' } >.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
243
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
244 =back
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
245
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
246 =head2 Response behaviour
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
247
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
248 Свойства отвечающие за поведение ответа.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
249
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
250 =over
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
251
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
252 =item C< [get,set] buffered >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
253
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
254 C< True > - то тело ответа пишется в буффер и будет отправлено при вызове метода C< Complete >,
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
255 заголовок также будет отправлен после вызова метода C< Complete >.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
256
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
257 C< False > - тело ответа пишется непосредственно в поток к клиенту, при этом заголовок
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
258 будет отправлен при первом обращении к свойству C< streamBody >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
259
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
260 Это свойство можно менять до первого обращения к потоку для записи в тело ответа.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
261
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
262 =item C< [get] streamOut >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
263
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
264 Стандартный вывод CGI приложения.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
265
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
266 =item C< [get] streamBody >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
267
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
268 Поток для записи в тело ответа.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
269
173
aaab45153411 minor bugfixes
sourcer
parents: 166
diff changeset
270 =item C< [get] isHeaderPrinted >
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
271
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
272 Признак того, что заголовок уже был отправлен клиенту.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
273
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
274 =back
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
275
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
276 =head1 METHODS
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
277
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
278 =over
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
279
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
280 =item C< Complete >
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
281
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
282 Завершает отправку ответа.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
283
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
284 =item C< Discard >
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
285
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
286 Отменяет отправку ответа, при этом если часть данных (например, заголовок)
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
287 уже была отправлена, выдает предупреждение в STDERR.
58
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
288
a35b60b16a99 Configuration, late activation
wizard
parents: 57
diff changeset
289 =back
57
bf59ee1cd506 Web application main class functionality
wizard
parents:
diff changeset
290
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
291 =head1 REMARKS
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
292
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
293 Данный объект является автозаполняемым, т.е. все его свойства можно задать через
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
294 именованные параметры конструктора.
67
9f5795a10939 Documentation, minor fixes
wizard
parents: 65
diff changeset
295
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 173
diff changeset
296 =cut