home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _fe1f43d0e6e14a52ad8e0c721c1eb70f < prev    next >
Text File  |  2000-03-15  |  760b  |  35 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})/$unreserved_escape{$1} || $1/ge;
  29.     $other->path("/") if $slash_path;
  30.     }
  31.     $other;
  32. }
  33.  
  34. 1;
  35.