make this work with cat 5.90080+
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / lib / ExternalCatty / Controller / Root.pm
1 package ExternalCatty::Controller::Root;
2 use strict;
3 use warnings;
4
5 use base qw/ Catalyst::Controller /;
6
7 __PACKAGE__->config( namespace => '' );
8
9 sub default : Private {
10     my ( $self, $c ) = @_;
11     $c->response->content_type('text/html; charset=utf-8');
12     $c->response->output( html( 'Root', 'Hello, test ☺!' ) );
13
14     # Newer Catalyst auto encodes UTF8, but this test case is borked and expects
15     # broken utf8 behavior.  We'll make a real UTF8 Test case separately.
16     $c->clear_encoding if $c->can('clear_encoding'); # Compat with upcoming Catalyst 5.90080
17 }
18
19 # redirect to a redirect
20 sub hello: Global {
21     my ( $self, $context ) = @_;
22     my $where = $context->uri_for('/');
23     $context->response->redirect($where);
24     return;
25 }
26
27 sub html {
28     my ( $title, $body ) = @_;
29     return qq[
30 <html>
31 <head>
32     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
33     <title>$title</title>
34 </head>
35 <body>$body</body>
36 </html>
37 ];
38 }
39
40 sub host : Global {
41     my ($self, $c) = @_;
42
43     my $host = $c->req->header('Host') || "<undef>";
44     my $html = html( $c->config->{name}, "Host: $host" );
45     $c->response->content_type("text/html");
46     $c->response->output($html);
47 }
48
49 1;
50