mod_perl question
Scott Penrose
scottp at dd.com.au
Mon Feb 9 19:10:52 CST 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/02/2004, at 11:46 AM, Carolyn Hicks wrote:
> On Tue, Feb 10, 2004 at 11:23:03AM +1100, CrashKat wrote:
>> Does anyone know how to get the entire url from an apache
>> request object?
>
> not with a single method, but you can put it together from its various
> components:
>
> my $url = 'http://'.$r->hostname.$r->uri;
There are three problems with the above approach.
1) It misses if you are using https - this has bitten me, years after
implementing code, people turn on HTTPS in the config and my scripts
break.
2) It is missing the port number - there is nothing stopping the user
either providing a redirect on a port or the administrator of the box
changing the port.
3) It does not necessarily come in with the host name that was selected
(ie: the HTTP 1.1)
Note that the way Apache passes this information in has changed
dramatically from 1.x to 2.x.
To fully build up a URL (and note that this is not necessarily the URL
it came in on) you will need.
* Scheme
* Host Name
* User / Password
* Port
* Path
* Query
Have a look at something like Apache::URI
There would be a binding in mod_perl Apache to allow you to get the URL
it came in on, but as a non-Mod Perl programmer I can't find it easily.
Scooter
> -carolyn
>
>
> --
> You have to consider that we're only made out of dust. That's
> admittedly
> not much to go on and we shouldn't forget that. But even considering, I
> mean it's a sort of bad beginning, we're not doing too bad.
> - Philip K. Dick
>
>
>
>
- --
Scott Penrose
Open source developer
http://linux.dd.com.au/
scottp at dd.com.au
Dismaimer: Open sauce usually ends up never coming out (of the bottle).
Please do not send me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQFAKC+fDCFCcmAm26YRAqe3AJ9akDbMUMk0Hp+pyolP8U5Du7t0mwCgg3vY
YsfzOLwN1MbcCKE9rpYtw6c=
=QSYW
-----END PGP SIGNATURE-----
More information about the Melbourne-pm
mailing list