Changeset 28

Show
Ignore:
Timestamp:
01/09/08 22:49:02 (6 years ago)
Author:
jesus
Message:

misdiagnosis. File::Temp was too old. But that's the one shipped with 5.8.8, so let's work around by opening with IO::File, refs #4

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/Mungo/MultipartFormData.pm

    r27 r28  
    88use Mungo; 
    99use Mungo::Request; 
     10use File::Temp; 
     11use IO::File; 
    1012eval "use Apache2::RequestIO;"; 
    1113 
     14package Mungo::MultipartFormData; 
    1215sub new { 
    1316  my $class = shift; 
     
    2427          delete $part->{payload}; 
    2528        } 
    26         eval { $part->{handle}->seek(0,0); }
     29        $part->{handle}->seek(0,0) if(UNIVERSAL::can($part->{handle}, 'seek'))
    2730      } 
    2831      else { 
     
    128131    if(length($self->{payload}) > $self->{maxmem}) { 
    129132      my($fh, $file) = tmpnam(); 
    130       if(!$fh) { 
     133      my $seekable = IO::File->new($file, "r+") if($fh); 
     134      if(!$seekable) { 
    131135        print STDERR "Could not create tmpfile (for POST storage)\n"; 
    132136        return undef; 
    133137      } 
     138      $fh->close(); 
    134139      unlink($file); 
    135       $self->{handle} = $fh
    136       $self->{handle}->print($self->{payload})
     140      $self->{handle} = $seekable
     141      $self->{handle}->print($self->{payload}) || die "cannot write to tmpfile"
    137142      delete $self->{payload}; 
    138143    }