| 1 | package CGI::Test::Input::URL; | ||||||||||
| 2 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | #################################################################### | ||||||||||
| 5 | # $Id: URL.pm 411 2011-09-26 11:19:30Z nohuhu@nohuhu.org $ | ||||||||||
| 6 | # $Name: cgi-test_0-104_t1 $ | ||||||||||
| 7 | #################################################################### | ||||||||||
| 8 | # | ||||||||||
| 9 | # Copyright (c) 2001, Raphael Manfredi | ||||||||||
| 10 | # | ||||||||||
| 11 | # You may redistribute only under the terms of the Artistic License, | ||||||||||
| 12 | # as specified in the README file that comes with the distribution. | ||||||||||
| 13 | # | ||||||||||
| 14 | # | ||||||||||
| 15 | # POST input data to be encoded with "application/x-www-form-urlencoded". | ||||||||||
| 16 | # | ||||||||||
| 17 | |||||||||||
| 18 | 11 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 11 | ▶ | use base qw(CGI::Test::Input); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | # | ||||||||||
| 23 | # ->new | ||||||||||
| 24 | # | ||||||||||
| 25 | # Creation routine | ||||||||||
| 26 | # | ||||||||||
| 27 | sub new | ||||||||||
| 28 | 17 | ▶ | { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 29 | 17 | my $this = bless { | |||||||||
| 30 | mime_type => 'application/x-www-form-urlencoded' | ||||||||||
| 31 | }, shift; | ||||||||||
| 32 | |||||||||||
| 33 | 17 | $this->_init; | |||||||||
| 34 | |||||||||||
| 35 | 17 | return $this; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | # DEPRECATED | ||||||||||
| 39 | sub make | ||||||||||
| 40 | 0 | ▶ | { # | ||||||||
|
Subroutine
make: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 41 | 0 | my $class = shift; | |||||||||
| 42 | 0 | return $class->new(@_); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | # | ||||||||||
| 46 | # Defined interface | ||||||||||
| 47 | # | ||||||||||
| 48 | |||||||||||
| 49 | # | ||||||||||
| 50 | # ->_build_data | ||||||||||
| 51 | # | ||||||||||
| 52 | # Rebuild data buffer from input fields. | ||||||||||
| 53 | # | ||||||||||
| 54 | sub _build_data | ||||||||||
| 55 | 17 | ▶ | { | ||||||||
|
Subroutine
_build_data: called CC=3 SCAR=11.0
| |||||||||||
| 56 | 17 | my $this = shift; | |||||||||
| 57 | |||||||||||
| 58 | # | ||||||||||
| 59 | # Note that file uploading fields get handled as any other field, meaning | ||||||||||
| 60 | # only the file path will be transmitted. | ||||||||||
| 61 | # | ||||||||||
| 62 | |||||||||||
| 63 | 17 | my $data = ''; | |||||||||
| 64 | |||||||||||
| 65 | # XXX field name encoding of special chars is the same as data? | ||||||||||
| 66 | |||||||||||
| 67 | 17 | foreach my $tuple (@{$this->_fields()}, @{$this->_files()}) | |||||||||
| 68 | { | ||||||||||
| 69 | 257 | my ($name, $value) = @$tuple; | |||||||||
| 70 | 257 | $value =~ s/([^a-zA-Z0-9_. -])/uc sprintf("%%%02x",ord($1))/eg; | |||||||||
| 71 | 257 | $value =~ s/ /+/g; | |||||||||
| 72 | 0 | $name =~ s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg; | |||||||||
| 73 | 257 | ▶ | $data .= '&' if length $data; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 257 | $data .= $name . '=' . $value; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 17 | return $data; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 11 | 1; | |||||||||
| 81 | |||||||||||
| 82 | =head1 NAME | ||||||||||
| 83 | |||||||||||
| 84 | CGI::Test::Input::URL - POST input encoded as application/x-www-form-urlencoded | ||||||||||
| 85 | |||||||||||
| 86 | =head1 SYNOPSIS | ||||||||||
| 87 | |||||||||||
| 88 | # Inherits from CGI::Test::Input | ||||||||||
| 89 | require CGI::Test::Input::URL; | ||||||||||
| 90 | |||||||||||
| 91 | my $input = CGI::Test::Input::URL->new(); | ||||||||||
| 92 | |||||||||||
| 93 | =head1 DESCRIPTION | ||||||||||
| 94 | |||||||||||
| 95 | This class represents the input for HTTP POST requests, encoded | ||||||||||
| 96 | as C<application/x-www-form-urlencoded>. | ||||||||||
| 97 | |||||||||||
| 98 | Please see L<CGI::Test::Input> for interface details. | ||||||||||
| 99 | |||||||||||
| 100 | =head1 AUTHORS | ||||||||||
| 101 | |||||||||||
| 102 | The original author is Raphael Manfredi. | ||||||||||
| 103 | |||||||||||
| 104 | Steven Hilton was long time maintainer of this module. | ||||||||||
| 105 | |||||||||||
| 106 | Current maintainer is Alexander Tokarev F<E<lt>tokarev@cpan.orgE<gt>>. | ||||||||||
| 107 | |||||||||||
| 108 | =head1 SEE ALSO | ||||||||||
| 109 | |||||||||||
| 110 | CGI::Test::Input(3). | ||||||||||
| 111 | |||||||||||
| 112 | =cut | ||||||||||
| 113 | |||||||||||