@@ -4,6 +4,8 @@ use warnings;
44use Test::More;
55plan tests => 71;
66
7+ use File::Spec;
8+ use File::Temp qw( tempfile) ;
79use HTTP::Request::Common;
810
911my $r = GET ' http://www.sn.no/' ;
@@ -117,7 +119,8 @@ is($r->content_type, "text/plain");
117119#
118120# POST for File upload
119121#
120- my $file = " test-$$ " ;
122+ my (undef , $file ) = tempfile();
123+ my $form_file = (File::Spec-> splitpath($file ))[-1];
121124open (FILE, " >$file " ) or die " Can't create $file : $! " ;
122125print FILE " foo\n bar\n baz\n " ;
123126close (FILE);
@@ -151,7 +154,7 @@ like($c[6], qr/^--\n/); # 5 parts + header & trailer
151154ok($c [2] =~ / ^Content-Disposition:\s *form-data;\s *name="email"/m );
152155ok($c [2] =~ / ^gisle\@ aas.no$ /m );
153156
154- ok($c [5] =~ / ^Content-Disposition:\s *form-data;\s *name="file";\s *filename="$file "/m );
157+ ok($c [5] =~ / ^Content-Disposition:\s *form-data;\s *name="file";\s *filename="$form_file "/m );
155158ok($c [5] =~ / ^Content-Type:\s *text\/ plain$ /m );
156159ok($c [5] =~ / ^foo\n bar\n baz/m );
157160
@@ -187,7 +190,7 @@ is($r->content_length, 13);
187190#
188191use HTTP::Request::Common qw( $DYNAMIC_FILE_UPLOAD) ;
189192
190- $file = " test- $$ " ;
193+ ( undef , $file ) = tempfile() ;
191194open (FILE, " >$file " ) or die " Can't create $file : $! " ;
192195for (1..1000) {
193196 print FILE " a" .. " z" ;
0 commit comments