home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _22a2661209175de9e26ed1b00a273373 < prev    next >
Encoding:
Text File  |  2004-06-01  |  828 b   |  36 lines

  1. package URI::http;
  2.  
  3. require URI::_server;
  4. @ISA=qw(URI::_server);
  5.  
  6. use strict;
  7. use vars qw(%unreserved_escape);
  8.  
  9. sub default_port { 80 }
  10.  
  11. sub canonical
  12. {
  13.     my $self = shift;
  14.     my $other = $self->SUPER::canonical;
  15.  
  16.     my $slash_path = defined($other->authority) &&
  17.         !length($other->path) && !defined($other->query);
  18.  
  19.     if ($slash_path || $$other =~ /%/) {
  20.     $other = $other->clone if $other == $self;
  21.     unless (%unreserved_escape) {
  22.         for ("A" .. "Z", "a" .. "z", "0" .."9",
  23.          "-", "_", ".", "!", "~", "*", "'", "(", ")"
  24.         ) {
  25.         $unreserved_escape{sprintf "%%%02X", ord($_)} = $_;
  26.         }
  27.     }
  28.     $$other =~ s/(%[0-9A-F]{2})/exists $unreserved_escape{$1} ?
  29.                                        $unreserved_escape{$1} : $1/ge;
  30.     $other->path("/") if $slash_path;
  31.     }
  32.     $other;
  33. }
  34.  
  35. 1;
  36.