make this work with cat 5.90080+
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / lib / ExternalCatty / Controller / Root.pm
CommitLineData
2140e65c 1package ExternalCatty::Controller::Root;
2use strict;
3use warnings;
4
5use base qw/ Catalyst::Controller /;
6
7__PACKAGE__->config( namespace => '' );
8
9sub default : Private {
10 my ( $self, $c ) = @_;
11 $c->response->content_type('text/html; charset=utf-8');
12 $c->response->output( html( 'Root', 'Hello, test ☺!' ) );
4c96289c 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
2140e65c 17}
18
19# redirect to a redirect
20sub hello: Global {
21 my ( $self, $context ) = @_;
22 my $where = $context->uri_for('/');
23 $context->response->redirect($where);
24 return;
25}
26
27sub 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
4ab99758 40sub 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
2140e65c 491;
50