Apache-CookieToQuery

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension Apache::CookieToQuery.

1.04  Mon Jul 15 23:30:04 2002
	- original version
1.05  Mon Jan 23 12:00:00 2006
	- minor documentation fixes

MANIFEST  view on Meta::CPAN

LICENSE
Changes
Makefile.PL
README
lib/Apache/CookieToQuery.pm
t/01_ini.t
MANIFEST
META.yml                                 Module meta-data (added by MakeMaker)

META.yml  view on Meta::CPAN

# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
name:         Apache-CookieToQuery
version:      1.05
version_from: lib/Apache/CookieToQuery.pm
installdirs:  site
requires:
    Apache::Cookie:                0

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    NAME         => 'Apache::CookieToQuery',
    VERSION_FROM => 'lib/Apache/CookieToQuery.pm', # finds $VERSION
    AUTHOR       => 'Alex Pavlovic (alex.pavlovic@taskforce-1.com)',
    ABSTRACT     => 'Rewrite requested uri by adding cookie information',
    PREREQ_PM   => {
	'Apache::Cookie'	=> '0', 
    }
);

README  view on Meta::CPAN

Apache::CookieToQuery(3U)ser Contributed Perl DocumentatiAopnache::CookieToQuery(3)



NNAAMMEE
               Apache::CookieToQuery - Rewrite query string by adding cookie information

SSYYNNOOPPSSIISS
               In httpd.conf or similiar

               <Location /YourLocation>
                       PerlAddVar IncludeCookie WSID
                       PerlAddVar IncludeCookie SID
                       PerlAddVar IncludeCookie QID
                       PerlAddVar CookieAlias WSID:WebSiteId
                       PerlAddVar CookieAlias QID:QueryId
                       PerlFixupHandler Apache::CookieToQuery
               </Location>

               Requests for http://yourhost/YourLocation?extra_params=12345

               Will now become rewritten so they look similiar to:

               http://yourhost/YourLocation?WebSiteId=<cookie WSID>;SID=<cookie SID>;QueryId=<cookie QID>;extra_params=12345

               Where <cookie WSID> for example is the value of cookie named WSID

DDEESSCCRRIIPPTTIIOONN
               This module will aid in adding cookie information to your query strings
               so that cgi scripts or handlers underneath can have immidate benefit

               It requires mod_perl + Apache web server with PERL_FIXUP callback hook enabled
               for more information on callback hooks refer to:
               http://perl.apache.org/docs/1.0/guide/install.html#Callback_Hooks

               IncludeCookie specifies cookie names that will be added, if none are specified
               any cookie name is taken into consideration

               CookieAlias specifies cookie name to look for and cookie name to alias it with
               when query string is rewritten, if alias for a cookie name does not exist,
               original cookie name will be used

               Please note that in the current implementation cookies always take precedence
               over query string paramaters

               This package should always be installed as PerlFixupHandler so that it can execute before
               standard PerlResponseHandler is called

BBUUGGSS

README  view on Meta::CPAN


       hhaannddlleerr

               Usage     : handler ( $apache )
               Purpose   : rewrites the query string of the original request
               Returns   : Server constant OK
               Argument  : apache instance



perl v5.8.7                       2006-01-24          Apache::CookieToQuery(3)

lib/Apache/CookieToQuery.pm  view on Meta::CPAN

package Apache::CookieToQuery;
use strict;

BEGIN {
	use vars qw ( $VERSION @COOKIE_NAMES %COOKIE_ALIASES );
	$VERSION     = 1.05;
}

use Apache;
use Apache::Constants qw( OK );
use CGI qw();
use Apache::Cookie;
use constant CONFIG_COOKIE_INCLUDE => 'IncludeCookie';
use constant CONFIG_COOKIE_ALIAS => 'CookieAlias';
use constant CONFIG_ALIAS_SEP => ':';

########################################### main pod documentation begin ##

=head1 NAME

	Apache::CookieToQuery - Rewrite query string by adding cookie information

=head1 SYNOPSIS

	In httpd.conf or similiar
	
	<Location /YourLocation>
		PerlAddVar IncludeCookie WSID
		PerlAddVar IncludeCookie SID
		PerlAddVar IncludeCookie QID
		PerlAddVar CookieAlias WSID:WebSiteId
		PerlAddVar CookieAlias QID:QueryId
		PerlFixupHandler Apache::CookieToQuery	
	</Location>

	Requests for http://yourhost/YourLocation?extra_params=12345
	
	Will now become rewritten so they look similiar to:
	
	http://yourhost/YourLocation?WebSiteId=<cookie WSID>;SID=<cookie SID>;QueryId=<cookie QID>;extra_params=12345
	
	Where <cookie WSID> for example is the value of cookie named WSID

=head1 DESCRIPTION

	This module will aid in adding cookie information to your query strings
	so that cgi scripts or handlers underneath can have immidate benefit
	
	It requires mod_perl + Apache web server with PERL_FIXUP callback hook enabled
	for more information on callback hooks refer to: 
	http://perl.apache.org/docs/1.0/guide/install.html#Callback_Hooks
	
	IncludeCookie specifies cookie names that will be added, if none are specified
	any cookie name is taken into consideration
	
	CookieAlias specifies cookie name to look for and cookie name to alias it with 
	when query string is rewritten, if alias for a cookie name does not exist, 
	original cookie name will be used 
	
	Please note that in the current implementation cookies always take precedence 
	over query string paramaters 
	
	This package should always be installed as PerlFixupHandler so that it can execute before
	standard PerlResponseHandler is called

=head1 BUGS

lib/Apache/CookieToQuery.pm  view on Meta::CPAN

	Returns   : Server constant OK
	Argument  : apache instance

=cut

################################################## subroutine header end ##

sub handler {
	my $apache = shift;
	my $cgi = CGI->new ( { $apache->args } );
	my $cookies = Apache::Cookie->new( $apache )->fetch;
        %COOKIE_ALIASES = split CONFIG_ALIAS_SEP, join CONFIG_ALIAS_SEP, $apache->dir_config->get ( CONFIG_COOKIE_ALIAS ) unless %COOKIE_ALIASES;
	@COOKIE_NAMES = $apache->dir_config->get ( CONFIG_COOKIE_INCLUDE ) unless @COOKIE_NAMES;
	my $cookie_names = @COOKIE_NAMES ? 
		\@COOKIE_NAMES : 
			[ keys %$cookies ];
	$cookies->{$_} and $cgi->param ( ( $COOKIE_ALIASES{$_} or $_ ), $cookies->{$_}->value ) for @$cookie_names;
	$apache->args ( $cgi->query_string );
	return OK;
}

t/01_ini.t  view on Meta::CPAN

# t/01_ini.t; just to load Apache::CookieToQuery by using it

$|++; 
print "1..1
";
my($test) = 1;

# 1 load
use Apache::CookieToQuery;
my($loaded) = 1;
$loaded ? print "ok $test
" : print "not ok $test
";
$test++;

# end of t/01_ini.t



( run in 1.130 second using v1.01-cache-2.11-cpan-e9199f4ba4c )