Apache2-ClickPath
view release on metacpan or search on metacpan
lib/Apache2/ClickPath.pm view on Meta::CPAN
(["']) # " oder ': Das ist $2 oder \2 (siehe unten)
(?:https?://\Q$host\E)? # evtl. Host
) # Das alles ist in $1
(?:/+\Q$sprefix\E[^/]+)?
( # $3 start
(?!(?:\w+:|\043)).*? # ein beliebiger nicht mit http:// o.ae.
# beginnender String (moeglichst kurz)
\2 # das schlieÃende Quote: $2
) # $3 ende
,xi;
# nach dieser regexp enthält entweder $2 oder $7 "http-equiv=refresh"
# $sess darf nur eingefügt werden, wenn eins von beiden nicht leer ist.
$re2=qr,( # $1 start "<meta ..."
<\s*meta\s+ # <meta> start
[^>]*? # evtl. anderes Zeug
) # $1 ende
( # $2 start optional "http-equiv=..."
\bhttp-equiv\s*=\s*(["']?)refresh\3
[^>]*? # evtl. anderes Zeug
)? # $2 ende
( # $4 start "content=" + opening quote
\bcontent\s*=\s*
(["']) # " oder ': Das ist \5 (siehe unten)
\s*\d+\s*;\s*url\s*=\s*
(?:https?://\Q$host\E)? # evtl. Host
) # $4 ende
(?:/+\Q$sprefix\E[^/]+)?
( # $6 start URL + closing quote
(?!\w+:).*? # ein beliebiger nicht mit http:// o.ae.
# beginnender String (so kurz wie möglich)
\5 # das schlieÃende Quote: $5
) # $6 ende
( # $7 start optional "http-equiv=..."
[^>]*? # evtl. anderes Zeug
\bhttp-equiv\s*=\s*(["']?)refresh\8
)? # $7 ende
,ix;
$re3=qr,( # $1 start
<\s*form\s+ # <a> start
[^>]*? # evtl. target=...
\baction\s*=\s* # href=
(["']) # " oder ': Das ist $2 oder \2 (siehe unten)
(?:https?://\Q$host\E)? # evtl. Host
) # Das alles ist in $1
(?:/+\Q$sprefix\E[^/]+)?
( # $3 start
(?!\w+:).*? # ein beliebiger nicht mit http:// o.ae.
# beginnender String (moeglichst kurz)
\2 # das schlieÃende Quote: $2
) # $3 ende
,xi;
$re4=qr,( # $1 start
<\s*i?frame\s+ # <a> start
[^>]*? # evtl. target=...
\bsrc\s*=\s* # href=
(["']) # " oder ': Das ist $2 oder \2 (siehe unten)
(?:https?://\Q$host\E)? # evtl. Host
) # Das alles ist in $1
(?:/+\Q$sprefix\E[^/]+)?
( # $3 start
(?!\w+:).*? # ein beliebiger nicht mit http:// o.ae.
# beginnender String (moeglichst kurz)
\2 # das schlieÃende Quote: $2
) # $3 ende
,xi;
} else {
$re1=qr,( # $1 start
<\s*a(?:rea)?\s+ # <a> start
.*? # evtl. target=...
\bhref\s*=\s* # href=
(["']) # " oder ': Das ist $2 oder \2 (siehe unten)
(?:https?://\Q$host\E)? # evtl. Host
) # Das alles ist in $1
(?:/+\Q$sprefix\E[^/]+)?
( # $3 start
/.*? # ein beliebiger mit /
# beginnender String (moeglichst kurz)
\2 # das schlieÃende Quote: $2
) # $3 ende
,xi;
# nach dieser regexp enthält entweder $2 oder $7 "http-equiv=refresh"
# $sess darf nur eingefügt werden, wenn eins von beiden nicht leer ist.
$re2=qr,( # $1 start "<meta ..."
<\s*meta\s+ # <meta> start
[^>]*? # evtl. anderes Zeug
) # $1 ende
( # $2 start optional "http-equiv=..."
\bhttp-equiv\s*=\s*(["']?)refresh\3
[^>]*? # evtl. anderes Zeug
)? # $2 ende
( # $4 start "content=" + opening quote
\bcontent\s*=\s*
(["']) # " oder ': Das ist \5 (siehe unten)
\s*\d+\s*;\s*url\s*=\s*
(?:https?://\Q$host\E)? # evtl. Host
) # $4 ende
(?:/+\Q$sprefix\E[^/]+)?
( # $6 start URL + closing quote
/.*? # ein beliebiger mit /
# beginnender String (so kurz wie möglich)
\5 # das schlieÃende Quote: $5
) # $6 ende
( # $7 start optional "http-equiv=..."
[^>]*? # evtl. anderes Zeug
\bhttp-equiv\s*=\s*(["']?)refresh\8
)? # $7 ende
,ix;
$re3=qr,( # $1 start
<\s*form\s+ # <a> start
[^>]*? # evtl. target=...
\baction\s*=\s* # href=
(["']) # " oder ': Das ist $2 oder \2 (siehe unten)
(?:https?://\Q$host\E)? # evtl. Host
) # Das alles ist in $1
(?:/+\Q$sprefix\E[^/]+)?
( # $3 start
/.*? # ein beliebiger /
# beginnender String (moeglichst kurz)
\2 # das schlieÃende Quote: $2
) # $3 ende
,xi;
$re4=qr,( # $1 start
<\s*i?frame\s+ # <a> start
[^>]*? # evtl. target=...
\bsrc\s*=\s* # href=
(["']) # " oder ': Das ist $2 oder \2 (siehe unten)
(?:https?://\Q$host\E)? # evtl. Host
) # Das alles ist in $1
(?:/+\Q$sprefix\E[^/]+)?
( # $3 start
/.*? # ein beliebiger /
# beginnender String (moeglichst kurz)
\2 # das schlieÃende Quote: $2
) # $3 ende
,xi;
}
# store the configuration
$f->ctx( +{
extra => '',
sess => $sess,
req => $the_request,
re => qr/(<[^>]*)$/,
re1 => $re1,
re2 => $re2,
re3 => $re3,
re4 => $re4,
} );
# output filters that alter content are responsible for removing
# the Content-Length header, but we only need to do this once.
$r->headers_out->unset('Content-Length');
}
# retrieve the filter context, which was set up on the first invocation
$context=$f->ctx;
$sess=$context->{sess};
$re1=$context->{re1};
$re2=$context->{re2};
$re3=$context->{re3};
$re4=$context->{re4};
$re0=$context->{re};
$the_request=$context->{req};
# now, filter the content
while( $f->read(my $buffer, 1024) ) {
# prepend any tags leftover from the last buffer or invocation
$buffer = $context->{extra} . $buffer if( length $context->{extra} );
# if our buffer ends in a split tag ('<strong' for example)
# save processing the tag for later
if (($context->{extra}) = $buffer =~ m/$re0/) {
$buffer = substr($buffer, 0, -length($context->{extra}));
}
if( length $the_request ) {
$buffer=~s!$re1!(substr($3, 0, 1) eq '/')
? $1.$sess.$3
: $1.$sess.$the_request.$3
!ge;
$buffer=~s!$re2!(length($2) or length($7))
? ((substr($6, 0, 1) eq '/')
lib/Apache2/ClickPath.pm view on Meta::CPAN
=item B<SESSION_START>
the request time of the request starting a session in seconds since 1/1/1970.
=item B<CGI_SESSION_AGE>
the session age in seconds, i.e. CURRENT_TIME - SESSION_START.
=item B<REMOTE_SESSION>
in case a friendly session was caught this variable contains it, see below.
=item B<REMOTE_SESSION_HOST>
in case a friendly session was caught this variable contains the host it
belongs to, see below.
=item B<EXPIRED_SESSION>
if a session has expired and a new one has been created the old session is
stored here.
=item B<INVALID_SESSION>
when a C<ClickPathMachineTable> is used a check is accomplished to ensure the
session was created by on of the machines of the cluster. If it was not
a message is written to the C<ErrorLog>, a new one is created and the invalid
session is written to this environment variable.
=item B<ClickPathMachineName>
when a C<ClickPathMachineTable> is used this variable contains the name of
the machine where the session has been created.
=item B<ClickPathMachineStore>
when a C<ClickPathMachineTable> is used this variable contains the address of
the session store in terms of C<Apache2::ClickPath::Store>.
=back
=head2 The Output Filter
The output filter is entirely skipped if the translation handler had not
set the C<CGI_SESSION> environment variable.
It prepends the session prefix and identifier to any C<Location> an
C<Refresh> output headers.
If the output C<Content-Type> is C<text/html> the body part is modified.
In this case the filter patches the following HTML tags:
=over 4
=item B<E<lt>a ... href="LINK" ...E<gt>>
=item B<E<lt>area ... href="LINK" ...E<gt>>
=item B<E<lt>form ... action="LINK" ...E<gt>>
=item B<E<lt>frame ... src="LINK" ...E<gt>>
=item B<E<lt>iframe ... src="LINK" ...E<gt>>
=item B<E<lt>meta ... http-equiv="refresh" ... content="N; URL=LINK" ...E<gt>>
In all cases if C<LINK> starts with a slash the current value of
C<CGI_SESSION> is prepended. If C<LINK> starts with
C<http://HOST/> (or https:) where C<HOST> matches the incoming C<Host>
header C<CGI_SESSION> is inserted right after C<HOST>. If C<LINK> is
relative and the incoming request URI had contained a session then C<LINK>
is left unmodified. Otherwize it is converted to a link starting with a slash
and C<CGI_SESSION> is prepended.
=back
=head2 Configuration Directives
All directives are valid only in I<server config> or I<virtual host> contexts.
=over 4
=item B<ClickPathSessionPrefix>
specifies the session prefix without the leading slash.
=item B<ClickPathMaxSessionAge>
if a session gets older than this value (in seconds) a new one is created
instead of continuing the old. Values of about a few hours should be good,
eg. 18000 = 5 h.
=item B<ClickPathMachine>
set this machine's name. The name is used with load balancers. Each
machine of a farm is assigned a unique name. That makes session identifiers
unique across the farm.
If this directive is omitted a compressed form (6 Bytes) of the server's
IP address is used. Thus the session is unique across the Internet.
In environments with only one server this directive can be given without
an argument. Then an empty name is used and the session is unique on
the server.
If possible use short or empty names. It saves bandwidth.
A name consists of letters, digits and underscores (_).
The generated session identifier contains the name in a slightly scrambled
form to slightly hide your infrastructure.
=item B<ClickPathMachineTable>
this is a container directive like C<< <Location> >> or C<< <Directory> >>.
It defines a 3-column table specifying the layout of your WEB-server cluster.
Each line consists of max. 3 fields. The 1st one is the IP address or name
the server is listening on. Second comes an optional machine name in in terms
of the C<ClickPathMachine> directive. If it is omitted each machine is
assigned it's line number within the table as name. This means that each
machine in a cluster must run with exactly the same table regarding the
line order. The optional 3rd field specifies the address where the session
store is accessible (see L<Apache2::ClickPath::Store> for more information.
( run in 0.496 second using v1.01-cache-2.11-cpan-e1769b4cff6 )