OpenInteract/Cookies/Apache.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 50 CC 1 SCAR 6.9
CC
1
Cov
0%
parse
2.0
bake
2.0
create_cookie
2.0
CRAP 2.0
1 package OpenInteract::Cookies::Apache;
2  
3 # $Id: Apache.pm,v 1.5 2002/01/02 02:43:53 lachoy Exp $
4  
5 use strict;
6 use Apache::Cookie;
7 use Data::Dumper qw( Dumper );
8  
9 @OpenInteract::Cookies::Apache::ISA = ();
10 $OpenInteract::Cookies::Apache::VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);
11  
12  
13 # Retrieve the cookies using Apache::Request
14  
15 sub parse {
16 my ( $class ) = @_;
17 my $R = OpenInteract::Request->instance;
18 my $cookie_info = Apache::Cookie->fetch;
19 foreach my $name ( keys %{ $cookie_info } ) {
20 my $value = $cookie_info->{ $name }->value;
21 $R->DEBUG && $R->scrib( 2, "Getting cookie $name to $value" );
22 $R->{cookie}{in}{ $name } = $value;
23 }
24 return $R->{cookie}{in};
25 }
26  
27  
28 # Cycle through the Apache::Cookie objects and
29 # call the bake method, which puts the appropriate header
30 # into the outgoing headers table.
31  
32 sub bake {
33 my ( $class ) = @_;
34 my $R = OpenInteract::Request->instance;
35 foreach my $name ( keys %{ $R->{cookie}{out} } ) {
36 $R->DEBUG && $R->scrib( 2, "Setting $name to value ", $R->{cookie}{out}{ $name }->value );
37 $R->{cookie}{out}{ $name }->bake;
38 }
39 return 1;
40 }
41  
42  
43 # Create a new cookie
44  
45 sub create_cookie {
46 my ( $class, $p ) = @_;
47 my $R = OpenInteract::Request->instance;
48 return $R->{cookie}{out}{ $p->{name} } =
49 Apache::Cookie->new( $R->apache,
50 -name => $p->{name},
51 -value => $p->{value},
52 -path => $p->{path},
53 -expires => $p->{expires} );
54 }
55  
56 1;
57  
58 __END__