fixed problems with mod_perl2
[catagits/Catalyst-Runtime.git] / t / 15post.t
1 package TestApp;
2
3 use Catalyst qw[-Engine=Test];
4
5 __PACKAGE__->action(
6     echo => sub {
7         my ( $self, $c ) = @_;
8
9         for my $field ( $c->req->headers->header_field_names ) {
10             my $header = ( $field =~ /^X-/ ) ? $field : "X-$field";
11             $c->res->headers->header(
12                 $header => $c->req->headers->header($field) );
13         }
14
15         $c->res->headers->content_type('text/plain');
16         $c->res->output('ok');
17     }
18 );
19
20 package main;
21
22 use Test::More tests => 5;
23 use Catalyst::Test 'TestApp';
24 use HTTP::Request::Common;
25
26 my $request = POST(
27     'http://localhost/echo',
28     'X-Whats-Cool' => 'Catalyst',
29     'Content-Type' => 'form-data',
30     'Content'      => [
31         catalyst => 'Rocks!',
32         file     => [$0],
33     ]
34 );
35
36 ok( my $response = request($request) );
37 ok( $response->content_type eq 'text/plain' );
38 ok( $response->headers->header('X-Content-Type') =~ /^multipart\/form-data/ );
39 ok( $response->headers->header('X-Content-Length') ==
40       $request->content_length );
41 ok( $response->headers->header('X-Whats-Cool') eq 'Catalyst' );