├── t ├── conf │ ├── .cvsignore │ └── extra.conf.in ├── .cvsignore ├── 00_compile.t ├── TEST.PL └── 01_url.t ├── .cvsignore ├── Changes ├── typemap ├── MANIFEST ├── Apache-Test └── lib │ └── Apache │ └── TestCanonicalName.pm ├── MANIFEST.SKIP ├── CanonicalName.xs ├── Makefile.PL ├── README └── lib └── Apache └── CanonicalName.pm /t/conf/.cvsignore: -------------------------------------------------------------------------------- 1 | *.conf 2 | *.pl 3 | *.pm 4 | -------------------------------------------------------------------------------- /t/.cvsignore: -------------------------------------------------------------------------------- 1 | htdocs 2 | logs 3 | httpd.core 4 | TEST 5 | -------------------------------------------------------------------------------- /.cvsignore: -------------------------------------------------------------------------------- 1 | blib 2 | Makefile 3 | pm_to_blib 4 | *.gz 5 | *.c 6 | *.bs 7 | 8 | -------------------------------------------------------------------------------- /t/00_compile.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use Test::More tests => 1; 3 | 4 | BEGIN { use_ok 'Apache::CanonicalName' } 5 | -------------------------------------------------------------------------------- /Changes: -------------------------------------------------------------------------------- 1 | Revision history for Perl extension Apache::CanonicalName 2 | 3 | 0.01 Mon Sep 2 17:33:49 2002 4 | - original version 5 | -------------------------------------------------------------------------------- /t/TEST.PL: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings FATAL => 'all'; 3 | 4 | use Apache::TestRunPerl; 5 | Apache::TestRunPerl->new->run(@ARGV); 6 | 7 | -------------------------------------------------------------------------------- /typemap: -------------------------------------------------------------------------------- 1 | TYPEMAP 2 | Apache T_APACHEOBJ 3 | 4 | OUTPUT 5 | T_APACHEOBJ 6 | sv_setref_pv($arg, \"${ntype}\", (void*)$var); 7 | 8 | INPUT 9 | T_APACHEOBJ 10 | r = sv2request_rec($arg, \"$ntype\", cv) 11 | 12 | -------------------------------------------------------------------------------- /t/01_url.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use Apache::Test; 3 | use Apache::TestRequest; 4 | 5 | plan tests => 1, have_lwp; 6 | 7 | { 8 | my $body = GET_BODY "/"; 9 | ok($body, qr!http://www.example.com:9999/bar/!); 10 | } 11 | -------------------------------------------------------------------------------- /t/conf/extra.conf.in: -------------------------------------------------------------------------------- 1 | PerlSetEnv PERL5LIB lib 2 | 3 | UseCanonicalName On 4 | ServerName www.example.com 5 | Port 9999 6 | 7 | 8 | SetHandler perl-script 9 | PerlHandler Apache::TestCanonicalName 10 | 11 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | Apache-Test/lib/Apache/TestCanonicalName.pm 2 | CanonicalName.xs 3 | Changes 4 | MANIFEST This list of files 5 | Makefile.PL 6 | README 7 | lib/Apache/CanonicalName.pm 8 | t/00_compile.t 9 | t/01_url.t 10 | t/TEST.PL 11 | t/conf/extra.conf.in 12 | typemap 13 | -------------------------------------------------------------------------------- /Apache-Test/lib/Apache/TestCanonicalName.pm: -------------------------------------------------------------------------------- 1 | package Apache::TestCanonicalName; 2 | use strict; 3 | use Apache::CanonicalName; 4 | 5 | sub handler { 6 | my $r = shift; 7 | $r->send_http_header; 8 | $r->print($r->construct_url("/bar/")); 9 | } 10 | 11 | 1; 12 | 13 | -------------------------------------------------------------------------------- /MANIFEST.SKIP: -------------------------------------------------------------------------------- 1 | \bRCS\b 2 | \bCVS\b 3 | ^MANIFEST\. 4 | ^Makefile$ 5 | ~$ 6 | \.old$ 7 | ^blib/ 8 | ^pm_to_blib 9 | ^MakeMaker-\d 10 | \.gz$ 11 | \.cvsignore 12 | \.bs$ 13 | \.c$ 14 | \.o$ 15 | t/TEST$ 16 | t/htdocs/index\.html 17 | t/httpd\.core 18 | t/logs 19 | t/conf/.*\.conf$ 20 | t/conf/.*\.pl 21 | t/conf/.*\.pm 22 | -------------------------------------------------------------------------------- /CanonicalName.xs: -------------------------------------------------------------------------------- 1 | #include "EXTERN.h" 2 | #include "perl.h" 3 | #include "XSUB.h" 4 | 5 | #include "mod_perl.h" 6 | 7 | char * 8 | _construct_url(Apache r, char *uri) { 9 | return ap_construct_url(r->pool, uri, r); 10 | } 11 | 12 | MODULE = Apache::CanonicalName PACKAGE = Apache::CanonicalName 13 | 14 | PROTOTYPES: DISABLE 15 | 16 | char * 17 | _construct_url(r, uri) 18 | Apache r; 19 | char *uri; 20 | CODE: 21 | RETVAL = _construct_url(r, uri); 22 | OUTPUT: 23 | RETVAL 24 | -------------------------------------------------------------------------------- /Makefile.PL: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | use Apache::src; 3 | 4 | my $inc = Apache::src->new->inc; 5 | 6 | WriteMakefile( 7 | 'NAME' => 'Apache::CanonicalName', 8 | 'VERSION_FROM' => 'lib/Apache/CanonicalName.pm', # finds $VERSION 9 | 'INC' => $inc, 10 | 'PREREQ_PM' => { 11 | Test::More => 0.32, 12 | mod_perl => 1.20, 13 | }, 14 | ); 15 | 16 | sub MY::test { 17 | if (eval "require Apache::TestMM") { 18 | Apache::TestMM::generate_script('t/TEST'); 19 | return Apache::TestMM->test; 20 | } 21 | 22 | return <header_out(Location => $r->construct_url("/bar/")); 14 | 15 | DESCRIPTION 16 | Apache::CanonicalName allows you to use "ap_construct_url" from inside 17 | mod_perl. It constructs url correctly using "UseCanonicalName" 18 | configurations. 19 | 20 | See http://httpd.apache.org/docs/mod/core.html#usecanonicalname for 21 | details. 22 | 23 | AUTHOR 24 | Tatsuhiko Miyagawa 25 | 26 | This library is free software; you can redistribute it and/or modify it 27 | under the same terms as Perl itself. 28 | 29 | SEE ALSO 30 | the Apache::URI manpage 31 | 32 | -------------------------------------------------------------------------------- /lib/Apache/CanonicalName.pm: -------------------------------------------------------------------------------- 1 | package Apache::CanonicalName; 2 | 3 | use strict; 4 | use vars qw($VERSION); 5 | $VERSION = 0.01; 6 | 7 | require DynaLoader; 8 | use base qw(DynaLoader); 9 | __PACKAGE__->bootstrap($VERSION) if $ENV{MOD_PERL}; 10 | 11 | package Apache; 12 | 13 | sub construct_url { 14 | my($r, $uri) = @_; 15 | Apache::CanonicalName::_construct_url($r, $uri); 16 | } 17 | 18 | 1; 19 | __END__ 20 | 21 | =head1 NAME 22 | 23 | Apache::CanonicalName - ap_construct_url port to mod_perl 24 | 25 | =head1 SYNOPSIS 26 | 27 | # in httpd.conf 28 | UseCanonicalName On 29 | ServerName www.example.com 30 | 31 | # in your mod_perl handler 32 | use Apache::CanonicalName; 33 | 34 | # this module adds construct_url method to Apache 35 | $r->header_out(Location => $r->construct_url("/bar/")); 36 | 37 | =head1 DESCRIPTION 38 | 39 | Apache::CanonicalName allows you to use C from 40 | inside mod_perl. It constructs url correctly using C 41 | configurations. 42 | 43 | See http://httpd.apache.org/docs/mod/core.html#usecanonicalname for details. 44 | 45 | =head1 AUTHOR 46 | 47 | Tatsuhiko Miyagawa Emiyagawa@bulknews.netE 48 | 49 | This library is free software; you can redistribute it and/or modify 50 | it under the same terms as Perl itself. 51 | 52 | =head1 SEE ALSO 53 | 54 | L 55 | 56 | =cut 57 | --------------------------------------------------------------------------------