[Catalyst] Testing Catalyst::Controller::REST based controllers

Damon Snyder drsnyder at influxmedia.com
Tue Feb 26 22:20:11 GMT 2008


Hi Ash,
Tried that, but no luck. I'm starting to wonder if  
Test::WWW::Mechanize::Catalyst or Test::WWW::Mechanize is clobbering  
the content portion of the request...

What versions of Test::WWW::Mechanize::Catalyst and  
Test::WWW::Mechanize are you using? I have 0.41 and 1.18 respectively.

Damon


On Feb 26, 2008, at 1:50 PM, Ash Berlin wrote:

>
> On 26 Feb 2008, at 21:43, Damon Snyder wrote:
>
>> Hi Ash, Everyone,
>> Thanks, that seemed to move me along further. I'm still unable to  
>> get the content part of the POST. I'm able to send the username and  
>> password through, but for some reason my controller gets empty  
>> content. Here is the request I've formed:
>>
>> ##### with mech object
>> my $t1 = Test::WWW::Mechanize::Catalyst->new;
>> $t1->add_header( 'Content-type' => 'text/x-json' );
>>
>> $req = new HTTP::Request ("POST", "http://localhost/rest/something",
>> 						['X-Username' => 'xxxxx', 'X-Password' => 'xxxxx'],
>> 						to_json({ stuff })
>> 						);
>> $res = $t1->request( $req );
>> ### fails with my Bad Request
>> #### end
>>
>>
>> In the above request, username and password are processed  
>> successfully, but no content is received.  I look for the content  
>> in $c->req->data.
>>
>> Here is the analogous LWP request:
>>
>> ##### LWP object
>> $ua = new LWP::UserAgent;
>> $req = new HTTP::Request ("POST", "http://localhost:3000/rest/something 
>> ",
>> 						['X-Username' => 'xxxxx', 'X-Password' => 'xxxxx'],
>> 						to_json({ stuff })
>> 						);
>> $req->content_type('text/x-json');
>> $res = $ua->request($req);
>> ### successfully creates the object
>> #### end
>
>
> Why not just change $ua->request there to $t1->request in your last  
> snippet (i.e. set content_type on the request object, not on the  
> mech object. It probably ignores it when you pass a Request object)
>
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/







More information about the Catalyst mailing list