| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Apache::AxKit::Plugin::AddXSLParams::Request; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 841 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 34 |  | 
| 4 | 1 |  |  | 1 |  | 1461 | use Apache::Constants; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | use Apache::Cookie; | 
| 6 |  |  |  |  |  |  | use Apache::Request; | 
| 7 |  |  |  |  |  |  | use Apache::URI; | 
| 8 |  |  |  |  |  |  | use vars qw($VERSION); | 
| 9 |  |  |  |  |  |  | $VERSION = '1.02'; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub handler { | 
| 13 |  |  |  |  |  |  | my $r = shift; | 
| 14 |  |  |  |  |  |  | my $uri = $r->uri; | 
| 15 |  |  |  |  |  |  | my $cgi = Apache::Request->instance($r); | 
| 16 |  |  |  |  |  |  | my @allowed_groups = split /\s+/, $r->dir_config('AxAddXSLParamGroups') || (); | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | # HTTP Headers | 
| 19 |  |  |  |  |  |  | if ( grep { $_ eq 'HTTPHeaders' } @allowed_groups ) { | 
| 20 |  |  |  |  |  |  | my $headers = $r->headers_in(); | 
| 21 |  |  |  |  |  |  | foreach my $h ( keys( %{$headers} ) ) { | 
| 22 |  |  |  |  |  |  | #warn "Processing header " .  lc( $h ) . " = " . $headers->{$h} . " \n"; | 
| 23 |  |  |  |  |  |  | if ( $h eq 'Cookie' ) { | 
| 24 |  |  |  |  |  |  | my $cookies = Apache::Cookie::parse( $headers->{$h} ); | 
| 25 |  |  |  |  |  |  | foreach my $oreo ( keys( %{$cookies} ) ) { | 
| 26 |  |  |  |  |  |  | $cgi->parms->set('request.cookie.' . $oreo => $cookies->{$oreo}->value ) if defined( $cookies->{$oreo}->value ); | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | $cgi->parms->set('request.headers.' . lc( $h ) => $headers->{$h}); | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | # Allow 'em to get Cookies header without all the other headers as an alternative | 
| 36 |  |  |  |  |  |  | elsif ( grep { $_ eq 'Cookies' } @allowed_groups ) { | 
| 37 |  |  |  |  |  |  | my $cookies = Apache::Cookie::parse( $r->header_in('Cookie') ); | 
| 38 |  |  |  |  |  |  | foreach my $oreo ( keys( %{$cookies} ) ) { | 
| 39 |  |  |  |  |  |  | $cgi->parms->set('request.cookie.' . $oreo => $cookies->{$oreo}->value ) if defined( $cookies->{$oreo}->value ); | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | # Here's the "Request-Common" group | 
| 45 |  |  |  |  |  |  | if ( grep { $_ eq 'Request-Common' } @allowed_groups ) { | 
| 46 |  |  |  |  |  |  | $cgi->parms->set('request.uri' => $r->uri ); | 
| 47 |  |  |  |  |  |  | $cgi->parms->set('request.filename' => $r->filename); | 
| 48 |  |  |  |  |  |  | $cgi->parms->set('request.method' => $r->method); | 
| 49 |  |  |  |  |  |  | $cgi->parms->set('request.path_info' => $r->path_info) if length( $r->path_info ) > 0; | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | # verbose URI parameters | 
| 53 |  |  |  |  |  |  | if ( grep { $_ eq 'VerboseURI' } @allowed_groups ) { | 
| 54 |  |  |  |  |  |  | my $parsed_uri = $r->parsed_uri; | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | my @uri_methods = qw( scheme hostinfo user password hostname port path rpath query fragment ); | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | foreach my $method ( @uri_methods ) { | 
| 59 |  |  |  |  |  |  | my $value = $parsed_uri->$method(); | 
| 60 |  |  |  |  |  |  | $cgi->parms->set('request.uri.' . $method => $value ) if length $value > 0; | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  | return OK; | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | 1; | 
| 67 |  |  |  |  |  |  | __END__ |