Apache-AxKit-Plugin-AddXSLParams-Request
view release on metacpan or search on metacpan
7475767778798081828384858687888990919293949596Param Prefix: request.headers.*
Implemented Fields:
The headers sent during a request vary somewhat from client to client;
this group will contain
*all
* the headers returned by the request
object's headers_in() method using the convention:
request.headers.
*fieldname
* where
*fieldname
* is name of the
given
HTTP
header field, forced to lower case.
If any HTTP Cookies are found in the headers, they will be parsed and
values
available as XSLT params using the naming convention:
request.cookies.
*yourcookiename
*. See the Cookies group below
for
an
alternative way to access cookies.
More common headers include:
*
accept
* content-type
*
accept
-charset
*
accept
-encoding
*
accept
-language
* connection
100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
* from
* referer
Examples:
<xsl:param name=
"request.headers.accept-language"
/>
<xsl:param name=
"request.headers.host"
/>
<xsl:param name=
"request.headers.user-agent"
/>
<xsl:param name=
"request.headers.referer"
/>
Cookies
Provides an
*alternative
* way to access the HTTP Cookies header
for
those folks that want to get at the cookie data but don't want to pull
in all of the other HTTP headers.
Param Prefix: request.cookies.*
Implemented Fields:
Cookie
values
are made available as params using the convention:
request.cookies.
*yourcookiename
*
Examples:
<xsl:param name=
"request.cookies.oreo"
/>
<xsl:param name=
"request.cookies.chocolate-chip"
/>
<xsl:param name=
"request.cookies.fortune"
/>
VerboseURI
Offers fine-grained access to the URI requested (via Apache::URI's
146147148149150151152153154155156157158159160161162163164
Examples:
<xsl:param name=
"request.uri.path"
/>
<xsl:param name=
"request.uri.scheme"
/>
<xsl:param name=
"request.uri.port"
/>
DEPENDENCIES
* libapreq
* Apache::Request
* Apache::Cookie
* Apache::URI
* AxKit (1.5 or greater)
AUTHOR
Kip Hampton, khampton
@totalcinema
.com
SEE ALSO
AxKit, Apache::Request, libapreq, Apache::Cookie, Apache::URI
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647use
strict;
use
Apache::Constants;
use
Apache::Cookie;
use
Apache::Request;
use
Apache::URI;
$VERSION
=
'1.02'
;
sub
handler {
my
$r
=
shift
;
my
$uri
=
$r
->uri;
my
$cgi
= Apache::Request->instance(
$r
);
my
@allowed_groups
=
split
/\s+/,
$r
->dir_config(
'AxAddXSLParamGroups'
) || ();
# HTTP Headers
if
(
grep
{
$_
eq
'HTTPHeaders'
}
@allowed_groups
) {
my
$headers
=
$r
->headers_in();
foreach
my
$h
(
keys
( %{
$headers
} ) ) {
#warn "Processing header " . lc( $h ) . " = " . $headers->{$h} . " \n";
if
(
$h
eq
'Cookie'
) {
my
$cookies
= Apache::Cookie::parse(
$headers
->{
$h
} );
foreach
my
$oreo
(
keys
( %{
$cookies
} ) ) {
$cgi
->parms->set(
'request.cookie.'
.
$oreo
=>
$cookies
->{
$oreo
}->value )
if
defined
(
$cookies
->{
$oreo
}->value );
}
}
$cgi
->parms->set(
'request.headers.'
.
lc
(
$h
) =>
$headers
->{
$h
});
}
}
# Allow 'em to get Cookies header without all the other headers as an alternative
elsif
(
grep
{
$_
eq
'Cookies'
}
@allowed_groups
) {
my
$cookies
= Apache::Cookie::parse(
$r
->header_in(
'Cookie'
) );
foreach
my
$oreo
(
keys
( %{
$cookies
} ) ) {
$cgi
->parms->set(
'request.cookie.'
.
$oreo
=>
$cookies
->{
$oreo
}->value )
if
defined
(
$cookies
->{
$oreo
}->value );
}
}
# Here's the "Request-Common" group
if
(
grep
{
$_
eq
'Request-Common'
}
@allowed_groups
) {
$cgi
->parms->set(
'request.uri'
=>
$r
->uri );
$cgi
->parms->set(
'request.filename'
=>
$r
->filename);
150151152153154155156157158159160161162163164165166167168169170B<Param Prefix>: request.headers.*
B<Implemented Fields>:
The headers sent during a request vary somewhat from client to client; this
group will contain I<all> the headers returned by the request object's
headers_in() method using the convention: request.headers.I<fieldname> where
I<fieldname> is name of the
given
HTTP header field, forced to lower case.
If any HTTP Cookies are found in the headers, they will be parsed and
values
available as XSLT
params using the naming convention: request.cookies.I<yourcookiename>. See the B<Cookies> group
below
for
an alternative way to access cookies.
More common headers include:
=over 4
=item * accept
=item * content-type
189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219=back
B<Examples>:
<xsl:param name="request.headers.accept-language"/>
<xsl:param name="request.headers.host"/>
<xsl:param name="request.headers.user-agent"/>
<xsl:param name="request.headers.referer"/>
=head1 B<Cookies>
Provides an I<alternative> way to access the HTTP Cookies header for those folks
that want to get at the cookie data but don't want to pull in all of the other
HTTP headers.
B<Param Prefix>: request.cookies.*
B<Implemented Fields>:
Cookie values are made available as params using the convention: request.cookies.I<yourcookiename>
B<Examples>:
<xsl:param name="request.cookies.oreo"/>
<xsl:param name="request.cookies.chocolate-chip"/>
<xsl:param name="request.cookies.fortune"/>
=head1 B<VerboseURI>
Offers fine-grained access to the URI requested (via Apache::URI's parse_uri() method.
253254255256257258259260261262263264265266267268269270271272273274275276277278279
<xsl:param name=
"request.uri.port"
/>
=head1 DEPENDENCIES
=over 4
=item * libapreq
=item * Apache::Request
=item * Apache::Cookie
=item * Apache::URI
=item * AxKit (1.5 or greater)
=back
=head1 AUTHOR
Kip Hampton, khampton@totalcinema.com
=head1 SEE ALSO
AxKit, Apache::Request, libapreq, Apache::Cookie, Apache::URI
=cut
( run in 0.253 second using v1.01-cache-2.11-cpan-d6f9594c0a5 )