Index: t/lib/TestApp/Controller/Dump.pm =================================================================== --- t/lib/TestApp/Controller/Dump.pm (revision 8511) +++ t/lib/TestApp/Controller/Dump.pm (working copy) @@ -29,4 +29,9 @@ $c->forward('TestApp::View::Dump::Response'); } +sub body : Action Relative { + my ( $self, $c ) = @_; + $c->forward('TestApp::View::Dump::Body'); +} + 1; Index: t/lib/TestApp/View/Dump/Body.pm =================================================================== --- t/lib/TestApp/View/Dump/Body.pm (revision 0) +++ t/lib/TestApp/View/Dump/Body.pm (revision 0) @@ -0,0 +1,11 @@ +package TestApp::View::Dump::Body; + +use strict; +use base qw[TestApp::View::Dump]; + +sub process { + my ( $self, $c ) = @_; + return $self->SUPER::process( $c, $c->request->{_body} ); # FIXME, accessor doesn't work? +} + +1; Index: t/aggregate/live_engine_request_uploads.t =================================================================== --- t/aggregate/live_engine_request_uploads.t (revision 8511) +++ t/aggregate/live_engine_request_uploads.t (working copy) @@ -6,7 +6,7 @@ use FindBin; use lib "$FindBin::Bin/../lib"; -use Test::More tests => 88; +use Test::More tests => 96; use Catalyst::Test 'TestApp'; use Catalyst::Request; @@ -244,6 +244,41 @@ } } +# Test PUT request with application/octet-stream file gets deleted + +{ + my $body; + + my $request = PUT( + 'http://localhost/dump/body/', + 'Content-Type' => 'application/octet-stream', + 'Content' => 'foobarbaz', + 'Content-Length' => 9, + ); + + ok( my $response = request($request), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + like( + $response->content, + qr/bless\( .* 'HTTP::Body::OctetStream' \)/s, + 'Content is a serialized HTTP::Body::OctetStream' + ); + + { + no strict 'refs'; + ok( + eval '$body = ' . substr( $response->content, 8 ), # FIXME - substr not needed in other test cases? + 'Unserialize HTTP::Body::OctetStream' + ) or warn $@; + } + + isa_ok( $body, 'HTTP::Body::OctetStream' ); + isa_ok($body->body, 'File::Temp'); + + ok( !-e $body->body->filename, 'Upload temp file was deleted' ); +} + # test uploadtmp config var {