| 1 | package Apache2::Controller::Log::DetectAbortedConnection; | ||
| 2 | |||
| 3 | # fwhew! that was a mouthful. | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Apache2::Controller::Log::DetectAbortedConnection - | ||
| 8 | helper handler for detecting cancelled connections to the client. | ||
| 9 | |||
| 10 | =head1 VERSION | ||
| 11 | |||
| 12 | Version 1.001.001 | ||
| 13 | |||
| 14 | =cut | ||
| 15 | |||
| 16 | 2 | ▶ | use version; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | our $VERSION = version->new('1.001.001'); | ||
| 18 | |||
| 19 | =head1 DESCRIPTION | ||
| 20 | |||
| 21 | You don't need to use this handler, probably. | ||
| 22 | |||
| 23 | This is pushed internally by L<Apache2::Controller::Session> | ||
| 24 | to detect in the PerlLogHandler phase if the connection has | ||
| 25 | been broken to the client before the server closes the connection. | ||
| 26 | |||
| 27 | So far it's only useful for the session, and because we now | ||
| 28 | use a C<PerlLogHandler> for session saving instead of the | ||
| 29 | C<PerlCleanupHandler> in prior versions. Using a | ||
| 30 | C<PerlCleanupHandler> caused | ||
| 31 | problems with synchronicity since the test scripts would | ||
| 32 | fire off a new request before Apache was done processing | ||
| 33 | the session saving from the prior request... I don't know | ||
| 34 | why it did this under prefork with C<Apache::Test>, | ||
| 35 | but it did. | ||
| 36 | |||
| 37 | So, I'm leaving it separate just in case it is useful for | ||
| 38 | something else in the future. | ||
| 39 | |||
| 40 | =head1 FUNCTIONS | ||
| 41 | |||
| 42 | =head2 handler | ||
| 43 | |||
| 44 | Sets C<< $r->pnotes->{a2c}{connection_aborted} >> with the | ||
| 45 | boolean results of C<< $r->connection->aborted() >> and returns. | ||
| 46 | |||
| 47 | I am not entirely sure why to cache this except that I couldn't | ||
| 48 | figure out any other way to manually override this state | ||
| 49 | even if you didn't abort the connection, if that's useful. | ||
| 50 | I may be over-planning here. | ||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 55 | 2 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 56 | |||
| 57 | 0 | ▶ | use Apache2::Connection (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 58 | use Apache2::RequestRec (); | ||
| 59 | use Apache2::Const -compile => qw( OK ); | ||
| 60 | |||
| 61 | use Log::Log4perl qw(:easy); | ||
| 62 | |||
| 63 | sub handler { | ||
| 64 | my ($r) = @_; | ||
| 65 | DEBUG "detecting aborted connection..."; | ||
| 66 | $r->pnotes->{a2c}{connection_aborted} ||= $r->connection->aborted(); | ||
| 67 | return Apache2::Const::OK; | ||
| 68 | } | ||
| 69 | |||
| 70 | 1; | ||
| 71 | |||
| 72 | =head1 SEE ALSO | ||
| 73 | |||
| 74 | L<Apache2::Controller::Session>, | ||
| 75 | |||
| 76 | L<Apache2::Controller>, | ||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | Mark Hedges, C<< <hedges at formdata.biz> >> | ||
| 81 | |||
| 82 | =head1 COPYRIGHT & LICENSE | ||
| 83 | |||
| 84 | Copyright 2008-2010 Mark Hedges, all rights reserved. | ||
| 85 | |||
| 86 | This program is free software; you can redistribute it and/or modify it | ||
| 87 | under the same terms as Perl itself. | ||
| 88 | |||
| 89 | This software is provided as-is, with no warranty | ||
| 90 | and no guarantee of fitness | ||
| 91 | for any particular purpose. | ||
| 92 | |||
| 93 | =cut | ||
| 94 | |||