[Jifty-commit] jifty branch, master, updated. 5972498d8f482c40c96c44b712859189069417d3

Jifty commits jifty-commit at lists.jifty.org
Tue Jun 22 14:13:29 EDT 2010


The branch, master has been updated
       via  5972498d8f482c40c96c44b712859189069417d3 (commit)
       via  42258652644d92bb476fafd698b988d771f36cc3 (commit)
      from  2b2117813f06b5594bf006174890c7672eba6c4b (commit)

Summary of changes:
 lib/Jifty/Handler.pm               |    1 -
 lib/Jifty/Request.pm               |    3 +-
 lib/Jifty/Response.pm              |   13 ++++++++++
 lib/Jifty/View/Static/Handler.pm   |    1 -
 t/TestApp/t/continuation-by-hand.t |   46 ++++++++++++++++++++++++++++++++++++
 5 files changed, 61 insertions(+), 3 deletions(-)
 create mode 100644 t/TestApp/t/continuation-by-hand.t

- Log -----------------------------------------------------------------
commit 42258652644d92bb476fafd698b988d771f36cc3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Jun 22 12:04:50 2010 -0400

    Assume a status of 200 unless otherwise specified
    
    This not only a helpful shortcut, but necessary when Jifty::Request
    objects are created by hand and stuffed into continuations --
    forgetting to specify the status is a very common failure mode.

diff --git a/lib/Jifty/Handler.pm b/lib/Jifty/Handler.pm
index 2fb3c01..25bc953 100644
--- a/lib/Jifty/Handler.pm
+++ b/lib/Jifty/Handler.pm
@@ -242,7 +242,6 @@ sub handle_request {
 
         Jifty->web->request( Jifty::Request->promote( $req ) );
         Jifty->web->response( Jifty::Response->new );
-        Jifty->web->response->status(200);
 
         $self->call_trigger('have_request');
 
diff --git a/lib/Jifty/Response.pm b/lib/Jifty/Response.pm
index 2525f56..c895ebc 100644
--- a/lib/Jifty/Response.pm
+++ b/lib/Jifty/Response.pm
@@ -20,6 +20,19 @@ extends 'Plack::Response';
 
 has 'error'   => (is => 'rw');
 
+=head2 new
+
+Default the status to 200.
+
+=cut
+
+sub new {
+    my $class = shift;
+    my $self = $class->SUPER::new(@_);
+    $self->status(200) unless $self->status;
+    return $self;
+}
+
 =head2 add_header NAME VALUE
 
 Deprecated.  Use header(NAME, VALUE)
diff --git a/lib/Jifty/View/Static/Handler.pm b/lib/Jifty/View/Static/Handler.pm
index 9b2fc43..85ad17d 100644
--- a/lib/Jifty/View/Static/Handler.pm
+++ b/lib/Jifty/View/Static/Handler.pm
@@ -229,7 +229,6 @@ sub send_http_header {
     my (undef, $length, $modified) = @_;
     my $now    = time();
     my $response = Jifty->web->response;
-    $response->status( 200 );
 
     # Expire in a year
     $response->header( 'Cache-Control' => 'max-age=31536000, public' );

commit 5972498d8f482c40c96c44b712859189069417d3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Jun 22 14:14:40 2010 -0400

    The Plack rewrite broke passing path => "/whatever"

diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index 4095951..97a49f1 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -117,6 +117,7 @@ sole argument.
 
 sub BUILD {
     my $self = shift;
+    my ($args) = @_;
 
     $self->setup_subrequest_env if Jifty->web->request;
 
@@ -125,7 +126,7 @@ sub BUILD {
     $self->{'fragments'} = {};
     $self->method('GET') unless $self->method;
 
-    $self->path("/") unless $self->path;
+    $self->path($args->{path}) if $args->{path};
     $self->arguments({});
     $self->template_arguments({});
 }
diff --git a/t/TestApp/t/continuation-by-hand.t b/t/TestApp/t/continuation-by-hand.t
new file mode 100644
index 0000000..b52bec4
--- /dev/null
+++ b/t/TestApp/t/continuation-by-hand.t
@@ -0,0 +1,46 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+Creating a custom request and saving it in a continuation should work.
+
+=cut
+
+BEGIN {chdir "t/TestApp"}
+use lib '../../lib';
+use Jifty::Test tests => 6, actual_server => 1;
+use Jifty::Test::WWW::Mechanize;
+
+my $server  = Jifty::Test->make_server;
+my $URL     = $server->started_ok;
+my $mech    = Jifty::Test::WWW::Mechanize->new();
+
+$mech->get_ok($URL, "Got original page");
+my $session = $mech->session;
+isa_ok($session, "Jifty::Web::Session", "Got the session out");
+
+my $cont;
+{
+    Jifty::Test->web;
+    local Jifty->web->{session} = $session;
+    my $req = Jifty::Request->new( path => "/otherplace" );
+    my $result = Jifty::Result->new;
+    $result->message("Result!");
+    my $resp = Jifty::Response->new;
+    $resp->result( yay => $result );
+    $cont = Jifty::Continuation->new(
+        request => $req,
+        response => $resp,
+    );
+}
+
+$mech->get_ok("$URL?J:CALL=".$cont->id, "Got answer");
+like($mech->uri, qr{/otherplace}, "Ended up at redirect");
+$mech->content_like(qr{Result!}, "Got result");
+
+
+1;
+

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list