authors cleanup
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Request.pm
index e370983..7210360 100644 (file)
@@ -403,6 +403,8 @@ Returns the protocol (HTTP/1.0 or HTTP/1.1) used for the current request.
 
 =head2 $req->query_parameters
 
+=head2 $req->query_params
+
 Returns a reference to a hash containing query string (GET) parameters. Values can
 be either a scalar or an arrayref containing scalars.
 
@@ -523,7 +525,8 @@ Returns a URI object for the current request. Stringifies to the URI text.
 =head2 $req->uri_with( { key => 'value' } );
 
 Returns a rewritten URI object for the current request. Key/value pairs
-passed in will override existing parameters. Unmodified pairs will be
+passed in will override existing parameters. You can remove an existing
+parameter by passing in an undef value. Unmodified pairs will be
 preserved.
 
 =cut
@@ -533,19 +536,20 @@ sub uri_with {
     
     carp( 'No arguments passed to uri_with()' ) unless $args;
 
-    for my $value ( values %$args ) {
+    foreach my $value ( values %$args ) {
         next unless defined $value;
         for ( ref $value eq 'ARRAY' ? @$value : $value ) {
             $_ = "$_";
-            utf8::encode( $_ );
+            utf8::encode( $_ ) if utf8::is_utf8($_);
         }
     };
     
-    my $uri = $self->uri->clone;
-    
+    my $uri   = $self->uri->clone;
+    my %query = ( %{ $uri->query_form_hash }, %$args );
+
     $uri->query_form( {
-        %{ $uri->query_form_hash },
-        %$args
+        # remove undef values
+        map { defined $query{ $_ } ? ( $_ => $query{ $_ } ) : () } keys %query
     } );
     return $uri;
 }
@@ -562,9 +566,7 @@ version string.
 
 =head1 AUTHORS
 
-Sebastian Riedel, C<sri@cpan.org>
-
-Marcus Ramberg, C<mramberg@cpan.org>
+Catalyst Contributors, see Catalyst.pm
 
 =head1 COPYRIGHT