my $uploadtmp = $class->config->{uploadtmp};
my $c = $class->context_class->new({ $uploadtmp ? (_uploadtmp => $uploadtmp) : ()});
+ $c->response->_context($c);
+
#surely this is not the most efficient way to do things...
$c->stats($class->stats_class->new)->enable($c->use_stats);
if ( $c->debug || $c->config->{enable_catalyst_header} ) {
required => 1,
lazy => 1,
);
+has _context => (
+ is => 'rw',
+ weak_ref => 1,
+ clearer => '_clear_context',
+);
sub output { shift->body(@_) }
my ( $self, $buffer ) = @_;
# Finalize headers if someone manually writes output
- $self->finalize_headers;
+ $self->_context->finalize_headers;
$buffer = q[] unless defined $buffer;
ok( my $response = request('http://localhost/streaming'), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Test-Header'), 'valid', 'Headers sent properly' );
SKIP:
{
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->content_type, 'text/plain', 'Response Content-Type' );
is( $response->content_length, -s $file, 'Response Content-Length' );
+ is( $response->header('X-Test-Header'), 'valid', 'Headers sent properly' );
is( $response->content, $buffer, 'Content is read from filehandle' );
ok( $response = request('http://localhost/action/streaming/body_glob'),
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->content_type, 'text/plain', 'Response Content-Type' );
is( $response->content_length, -s $file, 'Response Content-Length' );
+ is( $response->header('X-Test-Header'), 'valid', 'Headers sent properly' );
is( $response->content, $buffer, 'Content is read from filehandle' );
}
ok( my $response = request('http://localhost/action/streaming/body_large'), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Test-Header'), 'valid', 'Headers sent properly' );
is( $response->content_length, $size, 'Response Content-Length' );
is( $response->content, "\0" x $size, 'Content is read from filehandle' );
}
sub Catalyst::Log::error { }
}
+# Pretend to be Plugin::Session and hook finalize_headers to send a header
+
+sub finalize_headers {
+ my $c = shift;
+
+ $c->res->header('X-Test-Header', 'valid');
+
+ return $c->maybe::next::method(@_);
+}
+
# Make sure we can load Inline plugins.
package Catalyst::Plugin::Test::Inline;