stas        2003/12/18 18:40:43

  Modified:    lib/Apache compat.pm
               t/response/TestAPI uri.pm
               t/response/TestCompat apache_uri.pm
               .        Changes
  Log:
  APR::URI::unparse joins the crowd of the overridable compat functions
  this allows us to get rid of forcing the reloading of compat and real packages in
  the tests
  
  Revision  Changes    Path
  1.93      +20 -16    modperl-2.0/lib/Apache/compat.pm
  
  Index: compat.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -u -r1.92 -r1.93
  --- compat.pm 17 Dec 2003 19:59:47 -0000      1.92
  +++ compat.pm 19 Dec 2003 02:40:42 -0000      1.93
  @@ -119,6 +119,26 @@
   }
   EOI
   
  +    'APR::URI::unparse' => <<'EOI',
  +{
  +    require APR::URI;
  +    my $orig_sub = *APR::URI::unparse{CODE};
  +    *APR::URI::unparse = sub {
  +        my($uri, $flags) = @_;
  +
  +        if (defined $uri->hostname && !defined $uri->scheme) {
  +            # we do this only for back compat, the new APR::URI is
  +            # protocol-agnostic and doesn't fallback to 'http' when the
  +            # scheme is not provided
  +            $uri->scheme('http');
  +        }
  +
  +        $orig_sub->(@_);
  +    };
  +    $orig_sub;
  +}
  +EOI
  +
   );
   
   my %overridden_mp2_api = ();
  @@ -659,22 +679,6 @@
       $uri ||= $r->construct_url;
   
       APR::URI->parse($r->pool, $uri);
  -}
  -
  -{
  -    my $sub = *APR::URI::unparse{CODE};
  -    *APR::URI::unparse = sub {
  -        my($uri, $flags) = @_;
  -
  -        if (defined $uri->hostname && !defined $uri->scheme) {
  -            # we do this only for back compat, the new APR::URI is
  -            # protocol-agnostic and doesn't fallback to 'http' when the
  -            # scheme is not provided
  -            $uri->scheme('http');
  -        }
  -
  -        $sub->(@_);
  -    };
   }
   
   package Apache::Table;
  
  
  
  1.13      +0 -8      modperl-2.0/t/response/TestAPI/uri.pm
  
  Index: uri.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/uri.pm,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -u -r1.12 -r1.13
  --- uri.pm    3 Oct 2003 00:49:31 -0000       1.12
  +++ uri.pm    19 Dec 2003 02:40:43 -0000      1.13
  @@ -19,14 +19,6 @@
   sub handler {
       my $r = shift;
   
  -    # since Apache::compat redefines APR::URI::unparse and the test for
  -    # backcompat Apache::URI forces redefinition of APR::URI::unparse
  -    # (to get the right behavior during the test),
  -    # we need to force reload of APR::URI
  -    delete $INC{"APR/URI.pm"};
  -    no warnings 'redefine';
  -    require APR::URI;
  -
       plan $r, tests => 15;
   
       $r->args('query');
  
  
  
  1.3       +2 -9      modperl-2.0/t/response/TestCompat/apache_uri.pm
  
  Index: apache_uri.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestCompat/apache_uri.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- apache_uri.pm     10 Mar 2003 01:25:26 -0000      1.2
  +++ apache_uri.pm     19 Dec 2003 02:40:43 -0000      1.3
  @@ -13,9 +13,6 @@
   use Apache::compat ();
   use Apache::Constants qw(OK);
   
  -
  -
  -
   sub handler {
       my $r = shift;
   
  @@ -39,12 +36,7 @@
       #    }
   
       {
  -        # since Apache::compat redefines APR::URI::unparse and the test for
  -        # real APR::URI forces reload of APR::URI (to get the right behavior),
  -        # we need to force reload of Apache::compat
  -        delete $INC{"Apache/compat.pm"};
  -        require Apache::compat;
  -
  +        Apache::compat::override_mp2_api('APR::URI::unparse');
           # test the segfault in apr < 0.9.2 (fixed on mod_perl side)
           # passing only the /path
           my $parsed = $r->parsed_uri;
  @@ -53,6 +45,7 @@
           $parsed->port($r->get_server_port);
           #$parsed->scheme('http'); # compat defaults to 'http' like apache-1.3 did
           ok t_cmp($r->construct_url, $parsed->unparse);
  +        Apache::compat::restore_mp2_api('APR::URI::unparse');
       }
   
       OK;
  
  
  
  1.291     +3 -3      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.290
  retrieving revision 1.291
  diff -u -u -r1.290 -r1.291
  --- Changes   19 Dec 2003 02:25:43 -0000      1.290
  +++ Changes   19 Dec 2003 02:40:43 -0000      1.291
  @@ -27,9 +27,9 @@
   Apache::Connection::remote_addr to the Apache::compat overridable
   functions. [Stas]
   
  -Apache::compat's implementation of Apache::RequestRec::finfo and
  -Apache::RequestRec::notes is now overridable and not enabled by
  -default. [Stas]
  +Apache::compat's implementation of APR::URI::unparse,
  +Apache::RequestRec::finfo and Apache::RequestRec::notes is now
  +overridable and not enabled by default. [Stas]
   
   Apache::compat no longer enables functions which collide with mp2 API
   by default. It provides two new functions: override_mp2_api and
  
  
  

Reply via email to