use URI ();
use Catalyst::Exception ();
use URI::Escape;
+use HTTP::Request::Common;
use namespace::clean -except => 'meta';
=head1 VERSION
-Version 0.0032
+Version 0.0033
=cut
-our $VERSION = '0.0032';
+our $VERSION = '0.0033';
=head1 SYNOPSIS
it to your CGIs. Entries surrounded by C</> characters are considered regular
expressions.
-Default is to pass the whole of C<%ENV>, except for C<MOD_PERL> (that is, the
-default C<kill_env> is C<[ 'MOD_PERL' ]>.
+Default is to pass the whole of C<%ENV>, except for C<MOD_PERL> and
+C<CONTENT_TYPE> (that is, the default C<kill_env> is C<[ qw(MOD_PERL
+CONTENT_TYPE) ]>.
C<< $your_controller->{CGI}{username_field} >> should be the field for your user's name, which will be
read from C<< $c->user->obj >>. Defaults to 'username'.
local $/; $body_content = <$body>;
} else {
my $body_params = $c->req->body_parameters;
- if (%$body_params) {
+
+ if (my %uploads = %{ $c->req->uploads }) {
+ my $post = POST 'http://localhost/',
+ Content_Type => 'form-data',
+ Content => [
+ %$body_params,
+ map {
+ my $upl = $uploads{$_};
+ $_ => [
+ undef,
+ $upl->filename,
+ Content => $upl->slurp,
+ 'Content-Type' => $upl->type || 'application/octet-stream',
+ map (
+ $_ => $upl->headers->header($_)
+ ), grep !/^Content-(?:Type|Disposition)$/,
+ $upl->headers->header_field_names
+ ]
+ } keys %uploads
+ ];
+ $body_content = $post->content;
+ $req->content_type($post->header('Content-Type'));
+ } elsif (%$body_params) {
my $encoder = URI->new;
$encoder->query_form(%$body_params);
$body_content = $encoder->query;
$pass_env = [ $pass_env ] unless ref $pass_env;
my $kill_env = $self->{CGI}{kill_env};
- $kill_env = [ 'MOD_PERL' ] unless defined $kill_env;
+ $kill_env = [ 'MOD_PERL', 'CONTENT_TYPE' ] unless defined $kill_env;
$kill_env = [ $kill_env ] unless ref $kill_env;
if (@$pass_env) {