Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
828 B

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