X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FRequest.pm;h=329254b28a5ae1b76be624e870355437c4e7b31e;hb=b87d834e205e69128e7385f213ab32a7a7bc541f;hp=f75319b699f23a5e2f9cd327ec80136f217ca88a;hpb=ade3da0a3602627512932eef9af511247f11634f;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index f75319b..329254b 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -92,10 +92,10 @@ has _log => ( ); has io_fh => ( - is=>'ro', - predicate=>'has_io_fh', - lazy=>1, - builder=>'_build_io_fh'); + is=>'ro', + predicate=>'has_io_fh', + lazy=>1, + builder=>'_build_io_fh'); sub _build_io_fh { my $self = shift; @@ -103,16 +103,27 @@ sub _build_io_fh { || die "Your Server does not support psgix.io"; }; -has body_fh => ( - is=>'ro', - predicate=>'has_body_fh', - lazy=>1, - builder=>'_build_body_fh'); +has data_handlers => ( is=>'ro', isa=>'HashRef', default=>sub { +{} } ); -sub _build_body_fh { - (my $input_fh = shift->env->{'psgi.input'})->seek(0, 0); - return $input_fh; -}; +has body_data => ( + is=>'ro', + lazy=>1, + builder=>'_build_body_data'); + +sub _build_body_data { + my ($self) = @_; + my $content_type = $self->content_type; + my ($match) = grep { $content_type =~/$_/i } + keys(%{$self->data_handlers}); + + if($match) { + my $fh = $self->body; + local $_ = $fh; + return $self->data_handlers->{$match}->($fh, $self); + } else { + return undef; + } +} # Amount of data to read from input on each pass our $CHUNKSIZE = 64 * 1024; @@ -182,8 +193,6 @@ sub prepare_parameters { return $self->parameters; } - - sub _build_parameters { my ( $self ) = @_; my $parameters = {};