| 1 | =head1 NAME | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | Froody::Request::Apache | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =head1 DESCRIPTION | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | A Froody request object that slurps its data from a Apache request. | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =over 4 | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =cut | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | package Froody::Request::Apache; | ||||||||||||||||||||
| 14 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 0 | ▶ | eval q[ | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 17 | use Apache; | ||||||||||||||||||||
| 18 | use Apache::Request; | ||||||||||||||||||||
| 19 | 1; | ||||||||||||||||||||
| 20 | ]; | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 3 | ▶ | use Froody::Error; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 3 | ▶ | use Froody::Upload; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 3 | ▶ | use base qw( Froody::Request ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 27 | 0 | my $class = shift; | |||||||||||||||||||
| 28 | 0 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | my $vars = $self->get_params; | |||||||||||||||||||
| 31 | 0 | my $method = delete $vars->{method}; | |||||||||||||||||||
| 32 | 0 | $self->method($method); | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | ▶ | my $type = delete $vars->{'_type'} || delete $vars->{'_froody_type'}; | ||||||||||||||||||
|
Condition0%0/3
delete $vars->{'_type'} || delete $vars->{'_froody_type'}
MC/DC0%0/2
delete $vars->{'_type'} || delete $vars->{'_froody_type'}
delete $vars->{'_type'}
delete $vars->{'_froody_type'}
Truth table0%0/3
A || B
A= delete $vars->{'_type'}B= delete $vars->{'_froody_type'}
| |||||||||||||||||||||
| 35 | 0 | $self->type($type); | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | $self->params($vars); | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | return $self; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =item get_params | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | gets a hash of incoming params from apache, returns a hashref | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | ▶ | sub get_params { | ||||||||||||||||||
|
Subroutine
get_params: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 49 | 0 | my $self = shift; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | my $r = Apache->request; | |||||||||||||||||||
| 52 | 0 | my $ar = Apache::Request->instance( Apache->request ); | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | my %vars = map { | ||||||||||||||||||||
| 55 | 0 | my @results = $ar->param($_); | |||||||||||||||||||
| 56 | 0 | @results = map { Encode::decode("utf-8", $_, 1) } @results; | |||||||||||||||||||
| 57 | 0 | ▶ | ( $_ => scalar(@results) > 1 ? [ @results ] : $results[0] ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | } $ar->param(); | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 0 | foreach my $upload ( $ar->upload ) { | |||||||||||||||||||
| 61 | 0 | my $name = $upload->name; | |||||||||||||||||||
| 62 | $vars{$name} = -f $upload->tempname ? Froody::Upload | ||||||||||||||||||||
| 63 | ->new->fh($upload->fh) | ||||||||||||||||||||
| 64 | ->filename($upload->tempname) | ||||||||||||||||||||
| 65 | ->client_filename($upload->filename) | ||||||||||||||||||||
| 66 | 0 | ▶ | ->mime_type($upload->info->{'Content-Type'}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | : undef; | ||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 0 | return \%vars; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =back | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =head1 BUGS | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | None known. | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | Please report any bugs you find via the CPAN RT system. | ||||||||||||||||||||
| 80 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody> | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head1 AUTHOR | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | Copyright Fotango 2005. All rights reserved. | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | Please see the main L<Froody> documentation for details of who has worked | ||||||||||||||||||||
| 87 | on this project. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | This module is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 90 | the same terms as Perl itself. | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =head1 SEE ALSO | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | L<Froody>, L<Froody::Request> | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 3 | 1; | |||||||||||||||||||
| 99 | |||||||||||||||||||||