$c->finalize_error;
}
- if ( !$c->response->body && $c->response->status !~ /^(1|3)\d\d$/ ) {
+ if ( !$c->response->body_length && $c->response->status !~ /^(1|3)\d\d$/ ) {
$c->finalize_error;
}
- if ( $c->response->body && !$c->response->content_length ) {
- use bytes; # play safe with a utf8 aware perl
- $c->response->content_length( length $c->response->body );
+ if ( $c->response->body_length && !$c->response->content_length ) {
+ $c->response->content_length( $c->response->body_length );
}
my $status = $c->finalize_headers;
request => Catalyst::Request->new(
{
arguments => [],
+ body => undef,
cookies => {},
headers => HTTP::Headers->new,
parameters => {},
}
),
response => Catalyst::Response->new(
- { cookies => {}, headers => HTTP::Headers->new, status => 200 }
+ {
+ body => undef,
+ cookies => {},
+ headers => HTTP::Headers->new,
+ status => 200
+ }
),
stash => {},
state => 0
}
$c->prepare_request($engine);
- $c->prepare_path;
+ $c->prepare_connection;
$c->prepare_headers;
$c->prepare_cookies;
- $c->prepare_connection;
+ $c->prepare_path;
$c->prepare_action;
my $method = $c->req->method || '';
$req->arguments;
$req->base;
$req->body;
+ $req->body_length;
+ $req->body_ref;
$req->content_encoding;
$req->content_length;
$req->content_type;
print $c->request->body
+=item $req->body_length
+
+Returns the length of body in bytes.
+
+ print $c->request->body_length
+
+=cut
+
+sub body_length {
+ my $self = shift;
+
+ use bytes;
+
+ return 0 unless $self->body;
+ return length($self->body);
+}
+
+=item $req->body_ref
+
+Returns a reference to body.
+
+=cut
+
+sub body_ref {
+ my $self = shift;
+ return \$self->{body};
+}
+
=item $req->content_encoding
Shortcut to $req->headers->content_encoding
$resp = $c->response;
$resp->body;
+ $resp->body_length;
+ $resp->body_ref;
$resp->content_encoding;
$resp->content_length;
$resp->content_type;
Contains the final output.
+=item $resp->body_length
+
+Returns the length of body in bytes.
+
+ print $c->response->body_length
+
+=cut
+
+sub body_length {
+ my $self = shift;
+
+ use bytes;
+
+ return 0 unless $self->body;
+ return length($self->body);
+}
+
+=item $resp->body_ref
+
+Returns a reference to body.
+
+=cut
+
+sub body_ref {
+ my $self = shift;
+ return \$self->{body};
+}
+
=item $resp->content_encoding
Shortcut to $resp->headers->content_encoding