-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Philip M. Gollucci wrote:
>> In mp2 I am doing this:
>> -----------------------
>> use Apache2::ServerRec ();
>> use Apache2::ServerUtil ();
>> my $s = Apache2::ServerUtil->server();
>> warn "port = ",$s->port(),"\n";
>
> Try
> use Apache2::RequestUtil ();
> Apache2::RequestUtil->request()->get_server_port()
>
I would expect none of these solutions to work:
1. Solution:
- ------------
Where from should perl know which port you are refering to / interested
in or turn it the other way round what happens when you server listens
to more than one port on more than one IP addresses?
- ---------------8<-----------------
Listen 192.170.2.1:80
Listen 192.170.2.5:8000
- ---------------8<-----------------
I haven't read the HTTP-API docs of this function but in short this API
doesn't make any sense at least it should return a List and not a Scalar.
2. Solution:
- ------------
Where from should perl have a request in the startup-phase? The API in
request-context makes sense because an request is really made to one port.
> Though I don't see why your method doesn't work. I'll give it a spin in
> a bit.
>
You want is retrieving configuration values which can be done using
Apache2::Directive:
startup.pl:
- -----------------8<-----------------
use Apache2::Directive;
my $tree = Apache2::Directive::conftree();
my @ports = $tree->lookup('Listen');
foreach( @ports ) {
print "The server listens to port: $_\n";
}
- -----------------8<-----------------
httpd.conf:
- -----------------8<-----------------
# ....
# ....
PerlPostConfigRequire conf/startup.pl
- -----------------8<-----------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org
iD8DBQFDDDRvkVPeOFLgZFIRAhIxAJ9htGeljs/zdhHPRmCW1X9m0gCrDACeJVcA
TBm5467aUZbE2aRdXRK6wHg=
=IQBZ
-----END PGP SIGNATURE-----