Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Dev
Catalyst::Test and POSTing non-form data
 

Index | Next | Previous | View Flat


rkitover at io

Aug 18, 2008, 6:26 AM


Views: 967
Permalink
Catalyst::Test and POSTing non-form data

When I was writing tests for my C::C::REST stuff, I noticed that posting
stuff only worked if I set CATALYST_SERVER.

Here's a patch with a failing test:

Index: t/live_engine_request_body.t
===================================================================
--- t/live_engine_request_body.t (revision 8230)
+++ t/live_engine_request_body.t (working copy)
@@ -6,12 +6,13 @@
use FindBin;
use lib "$FindBin::Bin/lib";

-use Test::More tests => 18;
+use Test::More tests => 21;
use Catalyst::Test 'TestApp';

use Catalyst::Request;
use HTTP::Headers;
use HTTP::Request::Common;
+use HTTP::Request ();

{
my $creq;
@@ -75,3 +76,15 @@
is( $creq->content_length, $request->content_length,
'Catalyst::Request Content-Length' );
}
+
+{
+ my $request = HTTP::Request->new(POST => '/body');
+
+ $request->header('Content-Type' => 'text/xml');
+ $request->content('<item>chainsaw</item>');
+
+ ok( my $response = request($request), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+
+ is( $response->content, '<item>chainsaw</item>', '$c->req->body is
set' );
+}
Index: t/lib/TestApp/Controller/Body.pm
===================================================================
--- t/lib/TestApp/Controller/Body.pm (revision 0)
+++ t/lib/TestApp/Controller/Body.pm (revision 0)
@@ -0,0 +1,13 @@
+package TestApp::Controller::Body;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+sub dump_body : Path Args(0) {
+ my ( $self, $c ) = @_;
+
+ $c->res->body($c->req->body);
+}
+
+1;

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev[at]lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev

Subject User Time
Catalyst::Test and POSTing non-form data rkitover at io Aug 18, 2008, 6:26 AM
    Re: Catalyst::Test and POSTing non-form data rkitover at io Aug 18, 2008, 10:34 AM
        Re: Catalyst::Test and POSTing non-form data rkitover at io Aug 18, 2008, 11:03 AM
            Re: Catalyst::Test and POSTing non-form data claco at chrislaco Aug 18, 2008, 11:09 AM
                Re: Catalyst::Test and POSTing non-form data jon at jrock Aug 18, 2008, 11:50 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.