1 #!/usr/local/bin/perl -w
3 #################################################################
4 # Emanuele Zeppieri, Mark Stosberg #
5 # Shamelessly stolen from Data::FormValidator and CGI::Upload #
6 #################################################################
8 # Due to a bug in older versions of MakeMaker & Test::Harness, we must
9 # ensure the blib's are in @INC, else we might use the core CGI.pm
10 use lib qw(. ./blib/lib ./blib/arch);
14 use Test::More 'no_plan';
18 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
26 'SCRIPT_NAME' => '/test.cgi',
27 'SERVER_NAME' => 'perl.org',
28 'HTTP_CONNECTION' => 'TE, close',
29 'REQUEST_METHOD' => 'POST',
30 'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
31 'CONTENT_LENGTH' => 3285,
32 'SCRIPT_FILENAME' => '/home/usr/test.cgi',
33 'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
34 'HTTP_TE' => 'deflate,gzip;q=0.3',
36 'REMOTE_PORT' => '1855',
37 'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)',
38 'SERVER_PORT' => '80',
39 'REMOTE_ADDR' => '127.0.0.1',
40 'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY',
41 'SERVER_PROTOCOL' => 'HTTP/1.1',
42 'PATH' => '/usr/local/bin:/usr/bin:/bin',
43 'REQUEST_URI' => '/test.cgi',
44 'GATEWAY_INTERFACE' => 'CGI/1.1',
45 'SCRIPT_URL' => '/test.cgi',
46 'SERVER_ADDR' => '127.0.0.1',
47 'DOCUMENT_ROOT' => '/home/develop',
48 'HTTP_HOST' => 'www.perl.org'
51 for my $key (keys %myenv) {
52 $ENV{$key} = $myenv{$key};
57 for my $key (keys %myenv) {
63 #-----------------------------------------------------------------------------
64 # Simulate the upload (really, multiple uploads contained in a single stream).
65 #-----------------------------------------------------------------------------
71 open STDIN, '<t/upload_post_text.txt'
72 or die 'missing test file t/upload_post_text.txt';
78 my $test = "uploadInfo: basic test";
79 my $fh = $q->upload('300x300_gif');
80 is( $q->uploadInfo($fh)->{'Content-Type'}, "image/gif", $test);
86 my $test = "uploadInfo: works with second object instance";
87 my $fh = $q2->upload('300x300_gif');
88 is( $q2->uploadInfo($fh)->{'Content-Type'}, "image/gif", $test);