33 |
return $self; |
return $self; |
34 |
} |
} |
35 |
|
|
36 |
|
|
37 |
sub handler { |
sub handler { |
38 |
my ($self, $tx) = @_; |
my ($self, $tx) = @_; |
39 |
|
|
40 |
|
# XXX fake app so static dispatcher won't die on us |
41 |
|
{ |
42 |
|
package Fake::App; |
43 |
|
use base 'Mojo::Transaction'; |
44 |
|
sub app { |
45 |
|
my $self = shift; |
46 |
|
warn "## $self app ", @_; |
47 |
|
$self; |
48 |
|
} |
49 |
|
sub log { |
50 |
|
my $self = shift; |
51 |
|
warn "## $self log ",@_; |
52 |
|
return $self; |
53 |
|
} |
54 |
|
sub debug { |
55 |
|
my $self = shift; |
56 |
|
warn "## $self debug ",@_; |
57 |
|
return $self; |
58 |
|
} |
59 |
|
} |
60 |
|
bless $tx, 'Fake::App'; |
61 |
|
|
62 |
if ( $self->static->dispatch($tx) ) { |
if ( $self->static->dispatch($tx) ) { |
63 |
# warn "# static ",dump( $tx ); |
# warn "# static ",dump( $tx ); |
64 |
return $tx; |
return $tx; |
76 |
|
|
77 |
warn "# url $url params ",dump($params); |
warn "# url $url params ",dump($params); |
78 |
|
|
79 |
my $content_type = $server->request( $url, $params ); # fetch body |
my $request = $server->request( $url, $params ); # fetch body |
80 |
|
|
81 |
|
warn "# request ", dump( $request ); |
82 |
|
|
83 |
|
foreach ( 'content_type', 'code' ) { |
84 |
|
die "missing $_" unless defined $request->{$_}; |
85 |
|
} |
86 |
|
|
87 |
=for developer |
=for developer |
88 |
|
|
96 |
|
|
97 |
=cut |
=cut |
98 |
|
|
99 |
$tx->res->code(200); |
$tx->res->code( $request->{code} ); |
100 |
$tx->res->headers->content_type( $content_type ); |
$tx->res->headers->content_type( $request->{content_type} ); |
101 |
$tx->res->body( $body ); |
$tx->res->body( $body ); |
102 |
|
|
103 |
warn dump( $tx->res->headers ); |
warn dump( $tx->res->headers ); |