| 1 | =head1 NAME | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | Froody::Request::CGI | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =head1 DESCRIPTION | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | A Froody request object that slurps its data from a CGI request. | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =over 4 | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =cut | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | package Froody::Request::CGI; | ||||||||||||||||||||
| 14 | 10 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 10 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 10 | ▶ | use Froody::Error; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 10 | ▶ | use Froody::Upload; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 10 | ▶ | use base qw( Froody::Request ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 10 | ▶ | use CGI; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||
| 23 | 0 | my $class = shift; | |||||||||||||||||||
| 24 | 0 | ▶ | my $cgi = shift || CGI->new; | ||||||||||||||||||
|
Condition0%0/3
shift() || 'CGI'->new
MC/DC0%0/2
shift() || 'CGI'->new
shift()
'CGI'->new
Truth table0%0/3
A || B
A= shift()B= 'CGI'->new
| |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | my %vars = $cgi->Vars(); | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | ▶ | my $method = delete $vars{method} || ""; | ||||||||||||||||||
|
Condition0%0/2
delete $vars{'method'} || ''
MC/DC0%0/1
delete $vars{'method'} || ''
delete $vars{'method'}
Truth table0%0/2
A
A= delete $vars{'method'}
| |||||||||||||||||||||
| 31 | 0 | $self->method($method); | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 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'}
| |||||||||||||||||||||
| 34 | 0 | $self->type($type); | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | for (keys %vars) { | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | # XXX: multiple uploads??? | ||||||||||||||||||||
| 39 | 0 | ▶ | if (my $upload = $cgi->upload($_)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 0 | my $filename = $cgi->tmpFileName($upload); | |||||||||||||||||||
| 41 | 0 | my $client_filename = "".$cgi->param($_); | |||||||||||||||||||
| 42 | 0 | ▶ | my $type = ( $cgi->uploadInfo($upload) || {} )->{'Content-Type'}; | ||||||||||||||||||
|
Condition0%0/2
$cgi->uploadInfo($upload) || {}
MC/DC0%0/1
$cgi->uploadInfo($upload) || {}
$cgi->uploadInfo($upload)
Truth table0%0/2
A
A= $cgi->uploadInfo($upload)
| |||||||||||||||||||||
| 43 | 0 | $vars{$_} = Froody::Upload | |||||||||||||||||||
| 44 | ->new->fh($upload) | ||||||||||||||||||||
| 45 | ->filename($filename) | ||||||||||||||||||||
| 46 | ->client_filename($client_filename) | ||||||||||||||||||||
| 47 | ->mime_type($type); | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||
| 50 | # split multi-values params into a listref | ||||||||||||||||||||
| 51 | 0 | my @vals = split("\0",$vars{$_}); | |||||||||||||||||||
| 52 | 0 | ▶ | $vars{$_} = \@vals if (@vals > 1); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | # decopde params from unicode | ||||||||||||||||||||
| 55 | 0 | $vars{$_} = Encode::decode_utf8( $vars{$_}, 1 ); | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | # read cookies into the request as well. | ||||||||||||||||||||
| 60 | 0 | for ($cgi->cookie()) { | |||||||||||||||||||
| 61 | 0 | ▶ | next unless $_ eq 'cookie_session'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 0 | $vars{$_} = $cgi->cookie($_); | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | $self->params(\%vars); | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | return $self; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =back | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | =head1 BUGS | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | None known. | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | Please report any bugs you find via the CPAN RT system. | ||||||||||||||||||||
| 77 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody> | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =head1 AUTHOR | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | Copyright Fotango 2005. All rights reserved. | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | Please see the main L<Froody> documentation for details of who has worked | ||||||||||||||||||||
| 84 | on this project. | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | This module is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 87 | the same terms as Perl itself. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =head1 SEE ALSO | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | L<Froody>, L<Froody::Request> | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 10 | 1; | |||||||||||||||||||