5 plan skip_all => "Test Cases are Sketch for next release";
9 # Test case to check that we now send scalar and filehandle like
10 # bodys directly to the PSGI engine, rather than call $writer->write
11 # or unroll the filehandle ourselves.
14 package MyApp::Controller::User;
16 use base 'Catalyst::Controller';
25 sub get_user :Chained(/) PathPrefix CaptureArgs(0)
27 pop->stash(user=>\%user);
30 sub show :GET Chained(get_user) PathPart('') Args(0) {
32 my $user = $c->stash->{user};
34 'application/json' => sub { encode_json $user },
35 'text/html' => sub { "<p>Hi I'm $user->{name} and my age is $user->{age}</p>" }
39 sub post_user :POST Chained(root) PathPart('') Args(0) Consumes(HTMLForm,JSON)
42 %user = (%user, %{$c->req->body_data});
44 $c->res->location($c->uri_for( $self->action_for('show')));
47 $INC{'MyApp/Controller/User.pm'} = __FILE__;
52 use HTTP::Headers::ActionPack;
54 my $cn = HTTP::Headers::ActionPack->new
55 ->get_content_negotiator;
57 sub Catalyst::Response::format
61 my @formats = keys %formats;
63 my $accept = $self->_context->req->header('Accept') ||
67 $self->headers->header('Vary' => 'Accept');
68 $self->headers->header('Accepts' => (join ',', @formats));
70 if(my $which = $cn->choose_media_type(\@formats, $accept)) {
71 $self->content_type($which);
72 if(my $possible_body = $formats{$which}->($self)) {
73 $self->body($possible_body) unless $self->has_body || $self->has_write_fh;
77 $self->body("Method Not Acceptable");
88 use HTTP::Request::Common;
89 use Catalyst::Test 'MyApp';
91 ok my($res, $c) = ctx_request('/');