This file documents the revision history for Perl extension HTTP::Body.
+1.04 2008-06-23 16:00:00
+ - Added tmpdir() accessor to specify an alternate directory for temp files.
+ (jgoulah)
+
1.03 2008-04-07 08:20:00
- Set body value for XForms data. (Daniel Ruoso)
use Carp qw[ ];
-our $VERSION = '1.03';
+our $VERSION = '1.04';
our $TYPES = {
'application/octet-stream' => 'HTTP::Body::OctetStream',
length => 0,
param => {},
state => 'buffering',
- upload => {}
+ upload => {},
+ tmpdir => File::Spec->tmpdir(),
};
bless( $self, $body );
return $self->{upload};
}
+=item tmpdir
+
+Specify a different path for temporary files. Defaults to the system temporary path.
+
+=cut
+
+sub tmpdir {
+ my $self = shift;
+ $self->{tmpdir} = shift if @_;
+ return $self->{tmpdir};
+}
+
=back
=head1 AUTHOR
$part->{filename} = $filename;
if ( $filename ne "" ) {
- my $fh = File::Temp->new( UNLINK => 0 );
+ my $fh = File::Temp->new( UNLINK => 0, DIR => $self->tmpdir );
$part->{fh} = $fh;
$part->{tempname} = $fh->filename;
use strict;
use warnings;
-use Test::More tests => 60;
+use Test::More tests => 98;
use Cwd;
use HTTP::Body;
use File::Spec::Functions;
use IO::File;
use YAML;
+use File::Temp qw/ tempdir /;
my $path = catdir( getcwd(), 't', 'data', 'multipart' );
my $results = YAML::LoadFile( catfile( $path, "$test-results.yml" ) );
my $content = IO::File->new( catfile( $path, "$test-content.dat" ) );
my $body = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} );
+ my $tempdir = tempdir( 'XXXXXXX', CLEANUP => 1, DIR => File::Spec->tmpdir() );
+ $body->tmpdir($tempdir);
+
+ my $regex_tempdir = quotemeta($tempdir);
binmode $content, ':raw';
my $value = $body->upload->{$field};
for ( ( ref($value) eq 'ARRAY' ) ? @{$value} : $value ) {
+ like($_->{tempname}, qr{$regex_tempdir}, "has tmpdir $tempdir");
push @temps, delete $_->{tempname};
}
}