added Test::Pod support
[catagits/Catalyst-Runtime.git] / t / 16post.t
CommitLineData
49faa307 1package TestApp;
2
e05c5e3c 3use Catalyst qw[-Engine=Test];
49faa307 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
20package main;
21
22use Test::More tests => 5;
23use Catalyst::Test 'TestApp';
24use HTTP::Request::Common;
25
26my $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
36ok( my $response = request($request) );
37ok( $response->content_type eq 'text/plain' );
38ok( $response->headers->header('X-Content-Type') =~ /^multipart\/form-data/ );
39ok( $response->headers->header('X-Content-Length') ==
40 $request->content_length );
41ok( $response->headers->header('X-Whats-Cool') eq 'Catalyst' );