# 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');
+ return unless ($self->method eq 'POST' || $self->method eq 'PUT' || $self->method eq 'PATCH');
my ($match) = grep { $content_type =~/$_/i }
keys(%{$self->data_handlers});
my $fh = $self->body;
local $_ = $fh;
return $self->data_handlers->{$match}->($fh, $self);
- } else {
- Catalyst::Exception->throw("$content_type is does not have an available data handler");
+ } else {
+ Catalyst::Exception->throw(
+ sprintf '%s does not have an available data handler. Valid data_handlers are %s.',
+ $content_type, join ', ', sort keys %{$self->data_handlers}
+ );
}
}
# Check for definedness as you could read '0'
while ( defined ( my $chunk = $self->read() ) ) {
$self->prepare_body_chunk($chunk);
- $stream_buffer->print($chunk) if $stream_buffer;
+ next unless $stream_buffer;
+
+ $stream_buffer->print($chunk)
+ || die sprintf "Failed to write %d bytes to psgi.input file: $!", length( $chunk );
}
# Ok, we read the body. Lets play nice for any PSGI app down the pipe