my $body = Nginx_Body ( $r ); my $uploads = $body->upload; # hashref ## cleanup temp files undef $uploads; undef $body; sub Nginx_Body { my $r = shift; my $tmpdir = shift; my $content_type = $r->headers_in('Content-Type'); my $content_length = $r->headers_in('Content-Length'); my $body = HTTP::Body->new( $content_type, $content_length ); $body->tmpdir( $tmpdir ) if $tmpdir; my $length = $content_length; open my($bodyfh), '<:raw', $r->request_body_file or die $!; while ( $length ) { my $read = read( $bodyfh, my $buffer, ( $length < 8192 ) ? $length : 8192 ); my $bufferlength = length($buffer); die "IMPOSSIBLE $read != $bufferlength " if $read != $bufferlength ; $length -= $bufferlength; $body->add( $buffer ); } return $body; }