X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FRequest.pm;h=5e5730593328d2acb250004f82d88f40913f1e1a;hp=0fe34b0b4a72297648840c78d2609b7ceef43be4;hb=6dcc530761473f574ccde956e3a321b1dfb3d27e;hpb=c017b11bf96db335cf4efce1808d56d13651b10a diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index 0fe34b0..5e57305 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -11,6 +11,7 @@ use Stream::Buffered; use Hash::MultiValue; use Scalar::Util; use HTTP::Body; +use Catalyst::Exception; use Moose; use namespace::clean -except => 'meta'; @@ -118,7 +119,11 @@ has body_data => ( sub _build_body_data { my ($self) = @_; - my $content_type = $self->content_type; + + # Not sure if these returns should not be exceptions... + my $content_type = $self->content_type || return; + return unless ($self->method eq 'POST' || $self->method eq 'PUT'); + my ($match) = grep { $content_type =~/$_/i } keys(%{$self->data_handlers}); @@ -127,7 +132,7 @@ sub _build_body_data { local $_ = $fh; return $self->data_handlers->{$match}->($fh, $self); } else { - return undef; + Catalyst::Exception->throw("$content_type is does not have an available data handler"); } } @@ -522,6 +527,13 @@ data of the type 'application/json' and return access to that data via this method. You may define addition data_handlers via a global configuration setting. See L for more information. +If the POST is malformed in some way (such as undefined or not content that +matches the content-type) we raise a L with the error +text as the message. + +If the POSTed content type does not match an availabled data handler, this +will also raise an exception. + =head2 $req->body_parameters Returns a reference to a hash containing body (POST) parameters. Values can