start using Class::C3, may need to add a reinitalize bit later, not sure
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Response.pm
index 1a723dc..3c71fde 100644 (file)
@@ -1,19 +1,25 @@
 package Catalyst::Response;
 
+use Class::C3;
 use Moose;
+use HTTP::Headers;
 
-has cookies   => (is => 'rw');
-has body      => (is => 'rw');
+has cookies   => (is => 'rw', default => sub { {} });
+has body      => (is => 'rw', default => '');
 has location  => (is => 'rw');
-has status    => (is => 'rw');
+has status    => (is => 'rw', default => 200);
+has finalized_headers => (is => 'rw', default => 0);
 has headers   => (
   is      => 'rw',
   handles => [qw(content_encoding content_length content_type header)],
+  default => sub { HTTP::Headers->new() },
+  required => 1,
+  lazy => 1,
 );
-
 has _context => (
   is => 'rw',
   weak_ref => 1,
+  handles => ['write'],
 );
 
 sub output { shift->body(@_) }
@@ -149,10 +155,6 @@ Sets or returns the HTTP status.
 
 Writes $data to the output stream.
 
-=cut
-
-sub write { shift->_context->write(@_); }
-
 =head2 meta
 
 Provided by Moose
@@ -170,4 +172,6 @@ it under the same terms as Perl itself.
 
 =cut
 
+__PACKAGE__->meta->make_immutable;
+
 1;