Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

self_url() w/o CGI in MP2

by rkg (Hermit)
on Sep 02, 2003 at 18:41 UTC ( [id://288383]=perlquestion: print w/replies, xml ) Need Help??

rkg has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I'm using mod_perl 2, and I am trying to avoid loading CGI. Sans CGI, how can I determine self_url() to do a self-redirect? I tried this
my $self_uri = APR::URI->parse($r->pool,$r->uri)->unparse; $r->headers_out->set(Location => $self_uri . "&r2=1"); return Apache::REDIRECT;
but this gives a partial URL, not the full expansion. Any advice?
rkg

Replies are listed 'Best First'.
Re: self_url() w/o CGI in MP2
by tcf22 (Priest) on Sep 02, 2003 at 19:50 UTC
    This works on my apache server
    my $self_url = 'http://' . $ENV{SERVER_NAME} . $ENV{SCRIPT_NAME};
      Will that also give you the parameters passed in? I've got some reports that need to change the display parameter for various URLS, but leave all the other parameters the same ... Or, would I have to rebuild the parameter string myself?

      ------
      We are the carpenters and bricklayers of the Information Age.

      The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

      ... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

        No, but if you are doing a GET, this shoud do it.
        my $self_url = "http://$ENV{SERVER_NAME}/$ENV{SCRIPT_NAME}?$ENV{QUERY_ +STRING}";
        If you are doing a POST, then you'll have to read in STDIN to get your parameters.

        - Tom

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://288383]
Approved by blokhead
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-20 15:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found