[Jifty-commit] jifty branch, plack-rebased, created. e3634f1e5b1a47863dd6f1d0eba6525f43bfe773

Jifty commits jifty-commit at lists.jifty.org
Tue Mar 2 20:33:38 EST 2010


The branch, plack-rebased has been created
        at  e3634f1e5b1a47863dd6f1d0eba6525f43bfe773 (commit)

- Log -----------------------------------------------------------------
commit e3634f1e5b1a47863dd6f1d0eba6525f43bfe773
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Mar 3 08:38:03 2010 +0800

    we need to set request_uri when to redirect

diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index edb596f..9186dd7 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -22,6 +22,15 @@ has 'headers' => (is => 'rw', isa => 'HTTP::Headers', default => sub { HTTP::Hea
 has 'uri' => (is => 'rw', isa => 'URI', default => sub { URI->new('http:///') });
 has 'cookies' => (is => 'rw', isa => 'HashRef', default => sub { {} } );
 has 'scheme' => (is => "rw", isa => "Str", default => sub { 'http' });
+# we need to set request_uri sometimes
+has 'request_uri' => (
+    is      => "rw",
+    isa     => "Str",
+    lazy    => 1,
+    default => sub {
+        $_[0]->env->{REQUEST_URI} || '';
+    },
+);
 
 sub address     { $_[0]->env->{REMOTE_ADDR} }
 sub remote_host { $_[0]->env->{REMOTE_HOST} }
@@ -30,7 +39,7 @@ sub method      { $_[0]->env->{REQUEST_METHOD} = $_[1] if @_ > 1; $_[0]->env->{R
 sub request_method { Carp::carp "request_method is deprecated, use method instead"; goto \&method }
 sub port        { $_[0]->env->{SERVER_PORT} }
 sub user        { $_[0]->env->{REMOTE_USER} }
-sub request_uri { $_[0]->env->{REQUEST_URI} }
+#sub request_uri { $_[0]->env->{REQUEST_URI} }
 sub path_info   { $_[0]->env->{PATH_INFO} }
 sub script_name { $_[0]->env->{SCRIPT_NAME} }
 sub secure      { $_[0]->scheme eq 'https' }
diff --git a/lib/Jifty/Web.pm b/lib/Jifty/Web.pm
index 06efcb4..89312bc 100644
--- a/lib/Jifty/Web.pm
+++ b/lib/Jifty/Web.pm
@@ -713,6 +713,7 @@ sub redirect {
         # PATH_INFO, which is what $request->path is normally set to.
         # We should replicate that here.
         $request->path( URI::Escape::uri_unescape( $page->url ) );
+        $request->request_uri( URI->new($page->url)->path_query );
         $request->method("GET"); # ..effectively.
         $request->scheme($self->request->scheme);
         $request->continuation($self->request->continuation);
diff --git a/lib/Jifty/Web/Form.pm b/lib/Jifty/Web/Form.pm
index d8aae26..5ef94a2 100644
--- a/lib/Jifty/Web/Form.pm
+++ b/lib/Jifty/Web/Form.pm
@@ -200,7 +200,9 @@ sub start {
         }
     }
 
-    my $root = $self->submit_to || Jifty->web->request->top_request->path;
+    my $root = $self->submit_to
+      || URI->new(Jifty->web->request->top_request->request_uri)->path;
+    
     my $form_start = qq!<form method="post" action="!  . Jifty->web->escape( $root ) . qq!"!;
     $form_start .= qq! name="@{[ $self->name ]}"! if defined $self->name;
     $form_start .= qq! target="@{[ $self->target ]}"! if defined $self->target;

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


More information about the Jifty-commit mailing list