allow GET with body test to fail on lighttpd
[catagits/Catalyst-Runtime.git] / t / aggregate / live_engine_request_body.t
1 use strict;
2 use warnings;
3
4 use FindBin;
5 use lib "$FindBin::Bin/../lib";
6
7 use Test::More tests => 23;
8 use Catalyst::Test 'TestApp';
9
10 use Catalyst::Request;
11 use HTTP::Headers;
12 use HTTP::Request::Common;
13
14 {
15     my $creq;
16
17     my $request = POST(
18         'http://localhost/dump/request/',
19         'Content-Type' => 'text/plain',
20         'Content'      => 'Hello Catalyst'
21     );
22
23     ok( my $response = request($request), 'Request' );
24     ok( $response->is_success, 'Response Successful 2xx' );
25     is( $response->content_type, 'text/plain', 'Response Content-Type' );
26     like( $response->content, qr/'Catalyst::Request'/,
27         'Content is a serialized Catalyst::Request' );
28
29     {
30         no strict 'refs';
31         ok(
32             eval '$creq = ' . $response->content,
33             'Unserialize Catalyst::Request'
34         );
35     }
36
37     isa_ok( $creq, 'Catalyst::Request' );
38     is( $creq->method,       'POST',       'Catalyst::Request method' );
39     is( $creq->content_type, 'text/plain', 'Catalyst::Request Content-Type' );
40     is( $creq->{__body_type}, 'File::Temp' );
41     is( $creq->content_length, $request->content_length,
42         'Catalyst::Request Content-Length' );
43 }
44
45 {
46     my $creq;
47
48     my $request = POST(
49         'http://localhost/dump/request/',
50         'Content-Type' => 'text/plain',
51         'Content'      => 'x' x 100_000
52     );
53
54     ok( my $response = request($request), 'Request' );
55     ok( $response->is_success, 'Response Successful 2xx' );
56     is( $response->content_type, 'text/plain', 'Response Content-Type' );
57     like(
58         $response->content,
59         qr/^bless\( .* 'Catalyst::Request' \)$/s,
60         'Content is a serialized Catalyst::Request'
61     );
62
63     {
64         no strict 'refs';
65         ok(
66             eval '$creq = ' . $response->content,
67             'Unserialize Catalyst::Request'
68         );
69     }
70
71     isa_ok( $creq, 'Catalyst::Request' );
72     is( $creq->method,       'POST',       'Catalyst::Request method' );
73     is( $creq->content_type, 'text/plain', 'Catalyst::Request Content-Type' );
74     is( $creq->{__body_type}, 'File::Temp' );
75     is( $creq->content_length, $request->content_length,
76         'Catalyst::Request Content-Length' );
77 }
78
79 # 5.80 regression, see note in Catalyst::Plugin::Test::Plugin
80 {
81     my $request = GET(
82         'http://localhost/dump/response',
83         'Content-Type' => 'text/plain',
84         'Content'      => 'x' x 100_000
85     );
86
87     ok( my $response = request($request), 'Request' );
88     my $server = $response->header('server') || '';
89     local $TODO = 'lighttpd refuses GET with body'
90         if $server =~ /lighttpd/;
91
92     ok( $response->is_success, 'Response Successful 2xx' );
93     ok( $response->header('X-Have-Request-Body'), 'X-Have-Request-Body set' );
94 }
95