MPMinus/BaseHandlers.pm untested

filter: Statementstmt 0.0% 0 / 84 Branchbran 0.0% 0 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 18 Podpod 0.0% 0 / 14 totaltotal 0.0% 0 / 146 SCAR 56.1
CC
16
Cov
0%
LogHandler
12.0
Init
6.0
PostReadRequestHandler
6.0
CRAP 272.0
1 package MPMinus::BaseHandlers; # $Id: BaseHandlers.pm 145 2013-05-28 16:21:48Z minus $
2 use strict;
3
4 =head1 NAME
5
6 MPMinus::BaseHandlers - Base handlers of MPMinus
7
8 =head1 VERSION
9
10 Version 1.03
11
12 =head1 SYNOPSIS
13
14 package MPM::foo::Handlers;
15 use strict;
16
17 use MPMinus;
18 use base qw/MPMinus::BaseHandlers/;
19
20 sub new { bless {}, __PACKAGE__ }
21 sub handler {
22 my $r = shift;
23 my $m = MPMinus->m;
24 $m->conf_init($r, __PACKAGE__);
25 __PACKAGE__->Init($m);
26
27 # Handlers
28 $r->handler('modperl'); # modperl, perl-script
29
30 $r->set_handlers(PerlHeaderParserHandler => sub { __PACKAGE__->HeaderParserHandler($m) });
31 $r->set_handlers(PerlAccessHandler => sub { __PACKAGE__->AccessHandler($m) });
32 $r->set_handlers(PerlAuthenHandler => sub { __PACKAGE__->AuthenHandler($m) });
33 $r->set_handlers(PerlAuthzHandler => sub { __PACKAGE__->AuthzHandler($m) });
34 $r->set_handlers(PerlTypeHandler => sub { __PACKAGE__->TypeHandler($m) });
35 $r->set_handlers(PerlFixupHandler => sub { __PACKAGE__->FixupHandler($m) });
36 $r->set_handlers(PerlResponseHandler => sub { __PACKAGE__->ResponseHandler($m) });
37 $r->set_handlers(PerlLogHandler => sub { __PACKAGE__->LogHandler($m) });
38 $r->set_handlers(PerlCleanupHandler => sub { __PACKAGE__->CleanupHandler($m) });
39
40 return __PACKAGE__->InitHandler($m);
41 }
42 sub InitHandler {
43 my $pkg = shift;
44 my $m = shift;
45
46 # ... Setting Nodes ...
47 # $m->set( nodename => ' ... value ... ' ) unless $m->nodename;
48
49 ...
50
51 return __PACKAGE__->SUPER::InitHandler($m);
52 }
53
54 =head1 DESCRIPTION
55
56 Base handlers of MPMinus.
57
58 See L<http://perl.apache.org/docs/2.0/user/handlers/intro.html>
59
60 =head1 METHODS
61
62 =over 8
63
64 =item B<Init>
65
66 sub handler {
67 my $r = shift;
68 my $m = MPMinus->m;
69 $m->conf_init($r, __PACKAGE__);
70 __PACKAGE__->Init($m);
71
72 ...
73 }
74
75 NOTE: This is a required module call of MPM::foo::Handlers
76
77 =back
78
79 =head1 SERVER LIFE CYCLE HANDLERS
80
81 =over 8
82
83 =item B<OpenLogsHandler>
84
85 PerlModule MPM::foo::Handlers
86 PerlOpenLogsHandler MPM::foo::Handlers::OpenLogs
87
88 sub OpenLogs {
89 my ($conf_pool, $log_pool, $temp_pool, $s) = @_;
90 say("process $$ is born to reproduce");
91 return Apache2::Const::OK;
92 }
93
94 The open_logs phase happens just before the post_config phase.
95
96 Handlers registered by PerlOpenLogsHandler are usually used for opening module-specific log files
97 (e.g., httpd core and mod_ssl open their log files during this phase).
98
99 At this stage the STDERR stream is not yet redirected to error_log, and therefore any messages to
100 that stream will be printed to the console the server is starting from (if such exists).
101
102 Type : RUN_ALL
103 Scope : SRV
104
105 See L<http://perl.apache.org/docs/2.0/user/handlers/server.html>
106
107 =item B<PostConfigHandler>
108
109 PerlModule MPM::foo::Handlers
110 PerlPostConfigHandler MPM::foo::Handlers::PostConfig
111
112 sub PostConfig {
113 my ($conf_pool, $log_pool, $temp_pool, $s) = @_;
114 say("configuration is completed");
115 return Apache2::Const::OK;
116 }
117
118 The post_config phase happens right after Apache has processed the configuration files, before any
119 child processes were spawned (which happens at the child_init phase).
120
121 This phase can be used for initializing things to be shared between all child processes. You can do
122 the same in the startup file, but in the post_config phase you have an access to a complete
123 configuration tree (via Apache2::Directive).
124
125 Type : RUN_ALL
126 Scope : SRV
127
128 See L<http://perl.apache.org/docs/2.0/user/handlers/server.html>
129
130 =item B<ChildInitHandler>
131
132 PerlModule MPM::foo::Handlers
133 PerlChildInitHandler MPM::foo::Handlers::ChildInit
134
135 sub ChildInit {
136 my ($child_pool, $s) = @_;
137 say("process $$ is born to serve");
138 return Apache2::Const::OK;
139 }
140
141 The child_init phase happens immediately after the child process is spawned. Each child process
142 (not a thread!) will run the hooks of this phase only once in their life-time.
143
144 In the prefork MPM this phase is useful for initializing any data structures which should be private
145 to each process. For example Apache::DBI pre-opens database connections during this phase and
146 Apache2::Resource sets the process' resources limits.
147
148 Type : VOID
149 Scope : SRV
150
151 See L<http://perl.apache.org/docs/2.0/user/handlers/server.html>
152
153 =item B<ChildExitHandler>
154
155 PerlModule MPM::foo::Handlers
156 PerlChildExitHandler MPM::foo::Handlers::ChildExit
157
158 sub ChildExit {
159 my ($child_pool, $s) = @_;
160 my $m = MPMinus->m;
161 say("process $$ now exits");
162 return Apache2::Const::OK;
163 }
164
165 Opposite to the child_init phase, the child_exit phase is executed before the child process exits.
166 Notice that it happens only when the process exits, not the thread (assuming that you are using a
167 threaded mpm).
168
169 Type : RUN_ALL
170 Scope : SRV
171
172 See L<http://perl.apache.org/docs/2.0/user/handlers/server.html>
173
174 =back
175
176 See L<http://perl.apache.org/docs/2.0/user/handlers/server.html>
177
178 =head1 PROTOCOL HANDLERS
179
180 These handlers in this section are not considered. See user's guide
181 L<http://perl.apache.org/docs/2.0/user/index.html>
182
183 =over 8
184
185 =item B<PerlPreConnectionHandler>
186
187 The pre_connection phase happens just after the server accepts the connection, but before it is
188 handed off to a protocol module to be served. It gives modules an opportunity to modify the
189 connection as soon as possible and insert filters if needed. The core server uses this phase to
190 setup the connection record based on the type of connection that is being used. mod_perl itself
191 uses this phase to register the connection input and output filters.
192
193 In mod_perl 1.0 during code development Apache::Reload was used to automatically reload modified
194 since the last request Perl modules. It was invoked during post_read_request, the first HTTP
195 request's phase. In mod_perl 2.0 pre_connection is the earliest phase, so if we want to make sure
196 that all modified Perl modules are reloaded for any protocols and its phases, it's the best to set
197 the scope of the Perl interpreter to the lifetime of the connection via:
198
199 PerlInterpScope connection
200
201 and invoke the Apache2::Reload handler during the pre_connection phase. However this
202 development-time advantage can become a disadvantage in production--for example if a connection,
203 handled by HTTP protocol, is configured as KeepAlive and there are several requests coming on the
204 same connection and only one handled by mod_perl and the others by the default images handler, the
205 Perl interpreter won't be available to other threads while the images are being served.
206
207 Type : RUN_ALL
208 Scope : SRV
209
210 See L<http://perl.apache.org/docs/2.0/user/handlers/protocols.html>
211
212 =item B<PerlProcessConnectionHandler>
213
214 he process_connection phase is used to process incoming connections. Only protocol modules should
215 assign handlers for this phase, as it gives them an opportunity to replace the standard HTTP
216 processing with processing for some other protocols (e.g., POP3, FTP, etc.).
217
218 Type : RUN_FIRST
219 Scope : SRV
220
221 See L<http://perl.apache.org/docs/2.0/user/handlers/protocols.html>
222
223 =back
224
225 =head1 FILTERS
226
227 These handlers in this section are not considered. See user's guide, part Input and Output Filters
228 L<http://perl.apache.org/docs/2.0/user/handlers/filters.html>
229
230 # Set up handlers:
231 $r->add_input_filter(\&InputFilterHandler);
232 $r->add_output_filter(\&OutputFilterHandler);
233
234 # Realisation
235 sub InputFilterHandler {
236 my ($f, $bb, $mode, $block, $readbytes) = @_; # filter args
237 #debug(" -- InputFilterHandler N".($f->ctx?$f->ctx:'0')." (".$f->frec->name.")");
238
239 # runs on first invocation
240 unless ($f->ctx) {
241 $f->ctx(1);
242 }
243
244 # runs on all invocations
245 while ($f->read(my $buffer, 1024)) {
246 # process
247 }
248
249 # runs on the last invocation
250 if ($f->seen_eos) {
251 # finalize
252 }
253 return Apache2::Const::OK;
254 }
255 sub OutputFilterHandler {
256 my ($f, $bb, $mode, $block, $readbytes) = @_; # filter args
257 #debug(" -- OutputFilterHandler N".($f->ctx?$f->ctx:'0')." (".$f->frec->name.")");
258
259 # runs on first invocation
260 if ($f->ctx) {
261 $f->ctx( $f->ctx + 1 )
262 } else {
263 $f->r->headers_out->unset('Content-Length');
264 $f->ctx(1);
265 }
266
267 # runs on all invocations
268 while ($f->read(my $buffer, 1024)) {
269 $buffer =~ s/\r?\n/<br>/g;
270 #$f->print(CP1251toUTF8($buffer));
271 $f->print($buffer);
272
273 }
274
275 # runs on the last invocation
276 if ($f->seen_eos) {
277 $f->print('<div style="margin: 10px; padding: 10px; border: solid 1px red;"><b>OUTPUT_FILTER_TEXT_BANNER</b></div>');
278 }
279 return Apache2::Const::OK;
280 }
281
282 =over 8
283
284 =item B<PerlInputFilterHandler>
285
286 The PerlInputFilterHandler directive registers a filter, and inserts it into the relevant input
287 filters chain.
288
289 Type : VOID
290 Scope : DIR
291
292 See L<http://perl.apache.org/docs/2.0/user/handlers/filters.html>
293
294 =item B<PerlOutputFilterHandler>
295
296 The PerlOutputFilterHandler directive registers a filter, and inserts it into the relevant output filters chain.
297
298 Type : VOID
299 Scope : DIR
300
301 See L<http://perl.apache.org/docs/2.0/user/handlers/filters.html>
302
303 =item B<PerlSetInputFilter>
304
305 The SetInputFilter directive, documented at
306 L<http://httpd.apache.org/docs-2.0/mod/core.html#setinputfilter>, sets the filter or filters which
307 will process client requests and POST input when they are received by the server (in addition to
308 any filters configured earlier).
309
310 See L<http://perl.apache.org/docs/2.0/user/handlers/filters.html>
311
312 =item B<PerlSetOutputFilter>
313
314 The SetOutputFilter directive, documented at
315 L<http://httpd.apache.org/docs-2.0/mod/core.html#setoutputfilter> sets the filters which will
316 process responses from the server before they are sent to the client (in addition to any filters
317 configured earlier).
318
319 See L<http://perl.apache.org/docs/2.0/user/handlers/filters.html>
320
321 =back
322
323 =head1 HTTP PROTOCOL HANDLERS
324
325 =over 8
326
327 =item B<PostReadRequestHandler>
328
329 $r->set_handlers(
330 PerlPostReadRequestHandler =>
331 sub { __PACKAGE__->PostReadRequestHandler($m) }
332 );
333
334 The post_read_request phase is the first request phase and happens immediately after the request has
335 been read and HTTP headers were parsed.
336
337 This phase is usually used to do processing that must happen once per request. For example
338 Apache2::Reload is usually invoked at this phase to reload modified Perl modules.
339
340 Type : RUN_ALL
341 Scope : SRV
342
343 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
344
345 =item B<TransHandler>
346
347 $r->set_handlers(
348 PerlTransHandler =>
349 sub { __PACKAGE__->TransHandler($m) }
350 );
351
352 The translate phase is used to perform the manipulation of a request's URI. If no custom handler
353 is provided, the server's standard translation rules (e.g., Alias directives, mod_rewrite, etc.)
354 will be used. A PerlTransHandler handler can alter the default translation mechanism or completely
355 override it. This is also a good place to register new handlers for the following phases based on
356 the URI. PerlMapToStorageHandler is to be used to override the URI to filename translation.
357
358 Type : RUN_FIRST
359 Scope : SRV
360
361 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
362
363 =item B<MapToStorageHandler>
364
365 $r->set_handlers(
366 PerlMapToStorageHandler =>
367 sub { __PACKAGE__->MapToStorageHandler($m) }
368 );
369
370 The map_to_storage phase is used to perform the translation of a request's URI into a corresponding
371 filename. If no custom handler is provided, the server will try to walk the filesystem trying to
372 find what file or directory corresponds to the request's URI. Since usually mod_perl handler don't
373 have corresponding files on the filesystem, you will want to shortcut this phase and save quite a
374 few CPU cycles.
375
376 Type : RUN_FIRST
377 Scope : SRV
378
379 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
380
381 =item B<InitHandler>
382
383 $r->set_handlers(
384 PerlInitHandler =>
385 sub { __PACKAGE__->InitHandler($m) }
386 );
387
388 When configured inside any container directive, except <VirtualHost>, this handler is an alias for
389 PerlHeaderParserHandler described earlier. Otherwise it acts as an alias for
390 PerlPostReadRequestHandler described earlier.
391
392 It is the first handler to be invoked when serving a request.
393
394 Type : RUN_ALL
395
396 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
397
398 =item B<HeaderParserHandler>
399
400 $r->set_handlers(
401 PerlHeaderParserHandler =>
402 sub { __PACKAGE__->HeaderParserHandler($m) }
403 );
404
405 The header_parser phase is the first phase to happen after the request has been mapped to its
406 <Location> (or an equivalent container). At this phase the handler can examine the request headers
407 and to take a special action based on these. For example this phase can be used to block evil
408 clients targeting certain resources, while little resources were wasted so far.
409
410 Type : RUN_ALL
411 Scope : DIR
412
413 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
414
415 =item B<AccessHandler>
416
417 $r->set_handlers(
418 PerlAccessHandler =>
419 sub { __PACKAGE__->AccessHandler($m) }
420 );
421
422 The access_checker phase is the first of three handlers that are involved in what's known as
423 AAA: Authentication, Authorization, and Access control.
424
425 This phase can be used to restrict access from a certain IP address, time of the day or any other
426 rule not connected to the user's identity.
427
428 Type : RUN_ALL
429 Scope : DIR
430
431 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
432
433 =item B<AuthenHandler>
434
435 $r->set_handlers(
436 PerlAuthenHandler =>
437 sub { __PACKAGE__->AuthenHandler($m) }
438 );
439
440 The check_user_id (authen) phase is called whenever the requested file or directory is password
441 protected. This, in turn, requires that the directory be associated with AuthName, AuthType and at
442 least one require directive.
443
444 This phase is usually used to verify a user's identification credentials. If the credentials are
445 verified to be correct, the handler should return B<Apache2::Const::OK>. Otherwise the handler returns
446 B<Apache2::Const::HTTP_UNAUTHORIZED> to indicate that the user has not authenticated successfully. When
447 Apache sends the HTTP header with this code, the browser will normally pop up a dialog box that
448 prompts the user for login information.
449
450 Type : RUN_FIRST
451 Scope : DIR
452
453 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
454
455 =item B<AuthzHandler>
456
457 $r->set_handlers(
458 PerlAuthzHandler =>
459 sub { __PACKAGE__->AuthzHandler($m) }
460 );
461
462 The auth_checker (authz) phase is used for authorization control. This phase requires a successful
463 authentication from the previous phase, because a username is needed in order to decide whether a
464 user is authorized to access the requested resource.
465
466 As this phase is tightly connected to the authentication phase, the handlers registered for this
467 phase are only called when the requested resource is password protected, similar to the auth phase.
468 The handler is expected to return B<Apache2::Const::DECLINED> to defer the decision,
469 B<Apache2::Const::OK> to indicate its acceptance of the user's authorization, or
470 B<Apache2::Const::HTTP_UNAUTHORIZED> to indicate that the user is not authorized to access the
471 requested document.
472
473 Type : RUN_FIRST
474 Scope : DIR
475
476 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
477
478 =item B<TypeHandler>
479
480 $r->set_handlers(
481 PerlTypeHandler =>
482 sub { __PACKAGE__->TypeHandler($m) }
483 );
484
485 The type_checker phase is used to set the response MIME type (Content-type) and sometimes other bits
486 of document type information like the document language.
487
488 For example mod_autoindex, which performs automatic directory indexing, uses this phase to map the
489 filename extensions to the corresponding icons which will be later used in the listing of files.
490
491 Of course later phases may override the mime type set in this phase.
492
493 Type : RUN_FIRST
494 Scope : DIR
495
496 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
497
498 =item B<FixupHandler>
499
500 $r->set_handlers(
501 PerlFixupHandler =>
502 sub { __PACKAGE__->FixupHandler($m) }
503 );
504
505 The fixups phase is happening just before the content handling phase. It gives the last chance to
506 do things before the response is generated. For example in this phase mod_env populates the
507 environment with variables configured with SetEnv and PassEnv directives.
508
509 Type : RUN_ALL
510 Scope : DIR
511
512 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
513
514 =item B<ResponseHandler>
515
516 $r->set_handlers(
517 PerlResponseHandler =>
518 sub { __PACKAGE__->ResponseHandler($m) }
519 );
520
521 The handler (response) phase is used for generating the response. This is arguably the most
522 important phase and most of the existing Apache modules do most of their work at this phase.
523
524 This is the only phase that requires two directives under mod_perl.
525
526 Type : RUN_FIRST
527 Scope : DIR
528
529 NOTE: This method (ResponseHandler) returns B<Apache2::Const::NOT_FOUND> as default!
530
531 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
532
533 =item B<LogHandler>
534
535 $r->set_handlers(
536 PerlLogHandler =>
537 sub { __PACKAGE__->LogHandler($m) }
538 );
539
540 The log_transaction phase happens no matter how the previous phases have ended up. If one of the
541 earlier phases has aborted a request, e.g., failed authentication or 404 (file not found) errors,
542 the rest of the phases up to and including the response phases are skipped. But this phase is always
543 executed.
544
545 By this phase all the information about the request and the response is known, therefore the logging
546 handlers usually record this information in various ways (e.g., logging to a flat file or a database).
547
548 Type : RUN_ALL
549 Scope : DIR
550
551 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
552
553 =item B<CleanupHandler>
554
555 $r->set_handlers(
556 PerlCleanupHandler =>
557 sub { __PACKAGE__->CleanupHandler($m) }
558 );
559
560 There is no cleanup Apache phase, it exists only inside mod_perl. It is used to execute some code
561 immediately after the request has been served (the client went away) and before the request object
562 is destroyed.
563
564 There are several usages for this use phase. The obvious one is to run a cleanup code, for example
565 removing temporarily created files. The less obvious is to use this phase instead of PerlLogHandler
566 if the logging operation is time consuming. This approach allows to free the client as soon as the
567 response is sent.
568
569 Type : RUN_ALL
570 Scope : DIR
571
572 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
573
574 =back
575
576 See L<http://perl.apache.org/docs/2.0/user/handlers/http.html>
577
578 =head1 TYPES
579
580 =over 8
581
582 =item B<VOID>
583
584 Handlers of the type VOID will be all executed in the order they have been registered disregarding
585 their return values. Though in mod_perl they are expected to return Apache2::Const::OK.
586
587 =item B<RUN_FIRST>
588
589 Handlers of the type RUN_FIRST will be executed in the order they have been registered until the
590 first handler that returns something other than Apache2::Const::DECLINED. If the return value is
591 Apache2::Const::DECLINED, the next handler in the chain will be run. If the return value is
592 Apache2::Const::OK the next phase will start. In all other cases the execution will be aborted.
593
594 =item B<RUN_ALL>
595
596 Handlers of the type RUN_ALL will be executed in the order they have been registered until the first
597 handler that returns something other than Apache2::Const::OK or Apache2::Const::DECLINED.
598
599 For C API declarations see include/ap_config.h, which includes other types which aren't exposed by
600 mod_perl handlers
601
602 =back
603
604 See L<http://perl.apache.org/docs/2.0/user/handlers/intro.html>
605
606 =head1 SCOPES
607
608 The Scope row shows the location the directives are allowed to appear in:
609
610 =over 8
611
612 =item B<SRV>
613
614 Global configuration and <VirtualHost> (mnemonic: SeRVer). These directives are defined as RSRC_CONF
615 in the source code.
616
617 =item B<DIR>
618
619 <Directory>, <Location>, <Files> and all their regular expression variants (mnemonic: DIRectory).
620 These directives can also appear in .htaccess files. These directives are defined as OR_ALL in the
621 source code.
622
623 These directives can also appear in the global server configuration and <VirtualHost>.
624
625 =back
626
627 See L<http://perl.apache.org/docs/2.0/user/config/config.html>
628
629 =head1 AUTHOR
630
631 Serz Minus (Lepenkov Sergey) L<http://serzik.ru> E<lt>minus@mail333.comE<gt>
632
633 =head1 COPYRIGHT
634
635 Copyright (C) 1998-2013 D&D Corporation. All Rights Reserved
636
637 =head1 LICENSE
638
639 This program is free software: you can redistribute it and/or modify
640 it under the terms of the GNU General Public License as published by
641 the Free Software Foundation, either version 3 of the License, or
642 (at your option) any later version.
643
644 This program is distributed in the hope that it will be useful,
645 but WITHOUT ANY WARRANTY; without even the implied warranty of
646 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
647 GNU General Public License for more details.
648
649 See C<LICENSE> file
650
651 =cut
652
653 use vars qw($VERSION);
654 $VERSION = 1.03;
655
656 use MPMinus::Dispatcher;
657 use Apache2::Const;
658
659 #
660 # Init section
661 #
662 sub Init {
663 my $pkg = shift;
664 my $m = shift;
665
666 # Dispatcher Nodes
667 $m->set(disp => new MPMinus::Dispatcher($m->conf('project'),$m->namespace)) unless $m->disp;
668 $m->set(drec => $m->disp->get(-uri=>$m->conf('request_uri')));
669
670 return Apache2::Const::OK;
671 }
672
673 #
674 # HTTP Protocol Handlers
675 #
676
677 sub PostReadRequestHandler {
678 #############################################
679 # Ïåðâàÿ ôàçà ñðàçó ïîñëå ÷òåíèÿ çàãîëîâêîâ #
680 #############################################
681 my $pkg = shift;
682 my $m = shift;
683 my $record = $m->drec;
684 return $record->{PostReadRequest}->($m) if $record->{PostReadRequest};
685 return Apache2::Const::OK;
686 }
687 sub TransHandler {
688 #######################################
689 # Ôàçà RewriteURI - ìàíèïóëÿöèè ñ URI #
690 #######################################
691 my $pkg = shift;
692 my $m = shift;
693 my $record = $m->drec;
694 return $record->{Trans}->($m) if $record->{Trans};
695 return Apache2::Const::OK;
696 }
697 sub MapToStorageHandler {
698 ##########################################
699 # Ôàçà ïðèâÿçêè çàïðîñà ê ôàéëó íà äèñêå #
700 ##########################################
701 my $pkg = shift;
702 my $m = shift;
703 my $record = $m->drec;
704 return $record->{MapToStorage}->($m) if $record->{MapToStorage};
705 return Apache2::Const::OK;
706 }
707 sub InitHandler {
708 ######################
709 # Ôàçà èíèöèàëèçàöèè #
710 ######################
711 my $pkg = shift;
712 my $m = shift;
713 my $record = $m->drec;
714 return $record->{Init}->($m) if $record->{Init};
715 return Apache2::Const::OK;
716 }
717 sub HeaderParserHandler {
718 ###########################################
719 # Ôàçà ýòàïà ñîïîñòàâëåíèÿ Location è URL #
720 ###########################################
721 my $pkg = shift;
722 my $m = shift;
723 my $record = $m->drec;
724 return $record->{HeaderParser}->($m) if $record->{HeaderParser};
725 return Apache2::Const::OK;
726 }
727 sub AccessHandler {
728 ###################################################
729 # Ôàçà êîíòðîëÿ äîñòóïà ïî IP, âåðåìíè äíÿ è ò.ä. #
730 ###################################################
731 my $pkg = shift;
732 my $m = shift;
733 my $record = $m->drec;
734 return $record->{Access}->($m) if $record->{Access};
735 return Apache2::Const::OK;
736 }
737 sub AuthenHandler {
738 #################################
739 # Ôàçà ïðîâåðêè ëîãèíà è ïàðîëÿ #
740 #################################
741 my $pkg = shift;
742 my $m = shift;
743 my $record = $m->drec;
744 return $record->{Authen}->($m) if $record->{Authen};
745 return Apache2::Const::OK;
746 }
747 sub AuthzHandler {
748 ####################################
749 # Ôàçà ïðîâåðêè ïðàâ ïîëüçîâàòåëåÿ #
750 ####################################
751 my $pkg = shift;
752 my $m = shift;
753 my $record = $m->drec;
754 return $record->{Authz}->($m) if $record->{Authz};
755 return Apache2::Const::OK;
756 }
757 sub TypeHandler {
758 #################################
759 # Ôàçà óñòàíîâêè òèïà #
760 #################################
761 my $pkg = shift;
762 my $m = shift;
763 my $record = $m->drec;
764 return $record->{Type}->($m) if $record->{Type};
765 return Apache2::Const::OK;
766 }
767 sub FixupHandler {
768 #########################################
769 # Ôàçà ïîäãîòîâêè äàííûõ, ïðåäîáðàáîòêà #
770 #########################################
771 my $pkg = shift;
772 my $m = shift;
773 my $record = $m->drec;
774 return $record->{Fixup}->($m) if $record->{Fixup};
775 return Apache2::Const::OK;
776 }
777 sub ResponseHandler {
778 ##############################
779 # Ñåêöèÿ ôîðìèðîâàíèÿ îòâåòà #
780 ##############################
781 my $pkg = shift;
782 my $m = shift;
783 my $record = $m->drec;
784 return $record->{Response}->($m) if $record->{Response};
785 return Apache2::Const::OK;
786 }
787 sub LogHandler {
788 ##############################################################
789 # Ñåêöèÿ çàïèñè äàííûõ â ëîãè î ñîáûòèÿõ. Âûïîëíÿåòñÿ âñåãäà #
790 ##############################################################
791 my $pkg = shift;
792 my $m = shift;
793 $m->log("Index-record not found", "error") if $m->r->status() == Apache2::Const::NOT_FOUND;
794 my $record = $m->drec;
795 return $record->{Log}->($m) if $record->{Log};
796 return Apache2::Const::OK;
797 }
798 sub CleanupHandler {
799 ###################################
800 # Î÷èñòêà âñåõ âðåìåííûõ ñòðóêòóð #
801 ###################################
802 my $pkg = shift;
803 my $m = shift;
804 my $record = $m->drec;
805 return $record->{Cleanup}->($m) if $record->{Cleanup};
806 return Apache2::Const::OK;
807 }
808
809 1;
810