From: Jesse Sheidlower Date: Sat, 17 Sep 2005 01:17:54 +0000 (+0000) Subject: added $c->req->full_uri method (core from C::P::RequireSSL: thanks andyg!) X-Git-Tag: 5.7099_04~1241 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=696e8ae546bd96a821a9cef4c18c091697c2884f added $c->req->full_uri method (core from C::P::RequireSSL: thanks andyg!) --- diff --git a/Changes b/Changes index 3e0539a..4f62181 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ This file documents the revision history for Perl extension Catalyst. 5.34 2005-08-21 00:00:00 - Fixed mkpath in Catalyst::Helper (Autrijus Tang) + - added $c->req->full_uri method (Jesse Sheidlower) 5.33 2005-08-10 15:25:00 - Now with updated manifest. diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index 6611255..e7ce1f1 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -40,6 +40,7 @@ Catalyst::Request - Catalyst Request Class $req->content_type; $req->cookie; $req->cookies; + $req->full_uri; $req->header; $req->headers; $req->hostname; @@ -152,6 +153,32 @@ Returns a reference to a hash containing the cookies. print $c->request->cookies->{mycookie}->value; +=item $req->full_uri + +Returns the complete URI, with the parameter query string. + +=cut + +sub full_uri { + my $self = shift; + my $uri = $self->uri; + my $full_uri = $uri; + + if ( scalar $self->param ) { + my @params; + foreach my $arg ( sort keys %{ $self->params } ) { + if ( ref $self->params->{$arg} ) { + my $list = $self->params->{$arg}; + push @params, map { "$arg=" . $_ } sort @{$list}; + } else { + push @params, "$arg=" . $self->params->{$arg}; + } + } + $full_uri .= '?' . join( '&', @params ); + } + return $full_uri; +} + =item $req->header Shortcut to $req->headers->header