mod_perl question

Scott Penrose scottp at
Mon Feb 9 19:10:52 CST 2004

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 

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.


> -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
scottp at

Dismaimer: Open sauce usually ends up never coming out (of the bottle).

Please do not send me Word or PowerPoint attachments.
Version: GnuPG v1.2.3 (Darwin)


More information about the Melbourne-pm mailing list