revert to previous until I can fix it.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Request.pm
index 75ec6d9..117902e 100644 (file)
@@ -6,7 +6,7 @@ use base 'Class::Accessor::Fast';
 use IO::Socket qw[AF_INET inet_aton];
 
 __PACKAGE__->mk_accessors(
-    qw/action address arguments base cookies handle headers match method
+    qw/action address arguments cookies headers match method
       protocol query_parameters secure snippets uri user/
 );
 
@@ -44,7 +44,6 @@ Catalyst::Request - Catalyst Request Class
     $req->content_type;
     $req->cookie;
     $req->cookies;
-    $req->handle;
     $req->header;
     $req->headers;
     $req->hostname;
@@ -106,6 +105,23 @@ Returns a reference to an array containing the arguments.
 
 Contains the url base. This will always have a trailing slash.
 
+=cut
+
+sub base {
+    my ( $self, $base ) = @_;
+    
+    return $self->{base} unless $base;
+    
+    $self->{base} = $base;
+    
+    # set the value in path for backwards-compat
+    if ( $self->uri ) {
+        $self->path;
+    }
+    
+    return $self->{base};
+}
+
 =item $req->body
 
 Contains the message body of the request unless Content-Type is
@@ -188,10 +204,6 @@ Returns a reference to a hash containing the cookies.
 
     print $c->request->cookies->{mycookie}->value;
 
-=item $req->handle
-
-Request IO handle.
-
 =item $req->header
 
 Shortcut to $req->headers->header
@@ -334,19 +346,21 @@ alias for path, added for compability with L<CGI>
 
 sub path {
     my ( $self, $params ) = @_;
-    
-    if ( $params ) {
-        # base must always have a trailing slash
-        $params .= '/' unless ( $params =~ /\/$/ );
-        $self->uri->path( $params );
+
+    if ($params) {
+        $self->uri->path($params);
+    }
+    else {
+        return $self->{path} if $self->{path};
     }
 
-    my $path = $self->uri->path;
+    my $path     = $self->uri->path;
     my $location = $self->base->path;
     $path =~ s/^(\Q$location\E)?//;
     $path =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
     $path =~ s/^\///;
-    
+    $self->{path} = $path;
+
     return $path;
 }