You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bas Schulte <ba...@gmail.com> on 2006/09/01 19:53:36 UTC
Getting current url from request?
Hi,
I may be getting a bit rusty but I can't figure out which method to
use to get at the current url from the Apache request object. $r-uri
() gives me the path but not the schema, host and port.
Looking through perldoc Apache doesn't really give me a clue.
Anyone?
Re: Getting current url from request?
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Bas Schulte wrote:
> Hi,
>
> I sort of hoped I could simply get it directly from the Apache request
> object but apparently, I can't.
of course you can? if Apache knows it at all you can get to it from
mod_perl :)
see recipe 5.3 in the mod_perl developer's cookbook for the full
explanation of the differences between Apache::URI::parse() and
$r->parsed_uri(), but you probably want something like this (assuming
you were using mod_perl 1.0)
my $uri = Apache::URI->parse($r);
my $scheme = $uri->scheme;
my $port = $uri->port;
etc.
HTH
--Geoff
Re: Getting current url from request?
Posted by Bas Schulte <ba...@gmail.com>.
Hi,
I sort of hoped I could simply get it directly from the Apache
request object but apparently, I can't.
Turns out I had to have a CGI instance anyway so I'm using $cgi->url
() now, works fine.
Re: Getting current url from request?
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
David Nicol wrote:
> On 9/1/06, Jonathan Vanasco <mo...@2xlp.com> wrote:
>
>> $r-> the_request will give you the HTTP header
>
> Are not the standard CGI environment vars still available in modperl?
> This code snip will dump them for your inspection:
> print join "\n", "<pre>", (map {"$_ is $ENV{$_}"} sort keys %ENV),"</pre>";
Depends on SetHandler being modperl or perl-script
AND
PerlOptions +/- SetupEnv
--
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F 6A47 D55A 7172 A799 97F
"In all that I've done wrong I know I must have done something right to
deserve a hug every morning and butterfly kisses at night."
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ /
/ /|_/ / // /\ \/ /_/ / /__
/_/ /_/\_, /___/\___\_\___/
<___/
Re: Getting current url from request?
Posted by David Nicol <da...@gmail.com>.
On 9/1/06, Jonathan Vanasco <mo...@2xlp.com> wrote:
> $r-> the_request will give you the HTTP header
Are not the standard CGI environment vars still available in modperl?
This code snip will dump them for your inspection:
print join "\n", "<pre>", (map {"$_ is $ENV{$_}"} sort keys %ENV),"</pre>";
--
Although efforts are under way to mitigate the problem, this message
may contain flippancy, hyperbole and/or confusing assertions. Please
reply directly to fall2006sigfile@davidnicol.com for clarification of any points
appearing unclear, vague, cruel, frustrating, threatening, negative,
dilletantish or otherwise unprofessional before taking action based on
misintepretation or misconstruction of such points.
Re: Getting current url from request?
Posted by Jonathan Vanasco <mo...@2xlp.com>.
On Sep 1, 2006, at 1:53 PM, Bas Schulte wrote:
> I may be getting a bit rusty but I can't figure out which method to
> use to get at the current url from the Apache request object. $r-uri
> () gives me the path but not the schema, host and port.
$r->unparsed_uri will give you the GET args
$r-> the_request will give you the HTTP header
and this might help:
http://perl.apache.org/docs/2.0/api/Apache2/
Connection.html#C_base_server_
http://perl.apache.org/docs/2.0/api/Apache2/
Connection.html#C_client_socket_
( $c = $r->connection )
and
http://perl.apache.org/docs/2.0/api/Apache2/
RequestUtil.html#C_get_server_name_
http://perl.apache.org/docs/2.0/api/Apache2/
RequestUtil.html#C_get_server_port_
http://perl.apache.org/docs/2.0/api/Apache2/ServerRec.html#C_port_
( $s = $r->server() )