$q->self_url Unreliable

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi there all,

Is there a 100% reliable way to return the current URL of the script.
I have used $q->self_url but this doesn't seem to work on all servers. I'd
rather use cgi.pm than $ENV{} if poss.



Re: $q->self_url Unreliable

Julia De Silva wrote:
Quoted text here. Click to load it

Did you check the specification of the Common Gateway Interface if this
information is required?


Re: $q->self_url Unreliable

Quoted text here. Click to load it

Is there an official specification now? There wasn't as of several
years ago -- it was just sort of defined by the behavior of the NSCA
(then Apache) server behavior, plus a little web page at ncsa.uiuc.edu.

There is some question as to what is meant by current URL. Is it
the SCRIPT_NAME without PATH_INFO? Does it include the QUERY_STRING?

The CGI.pm url() method would seem to be what you want, as it can
do any of the above combinations.

Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com /

Be patient. God isn't finished with me yet.  -- unknown

Re: $q->self_url Unreliable

Mike Heins wrote:

Quoted text here. Click to load it



The current URL would be in my opinion what one sees in the addressbar
when the script is called.

"self_url() will return a URL, that, when selected, will reinvoke this
script with all its state information intact. "

If self_url excludes either PATH_INFO or QUERY_STRING it's wrongly
implemented IMNSHO, or the documentation is incorrect (I consider
PATH_INFO state information too).

"    Semicolon-delimited query strings are always accepted, but will not
     be emitted by self_url() and query_string() unless the -
     newstyle_urls pragma is specified.
     This became the default in version 2.64."

John                   Small Perl scripts: http://johnbokma.com/perl/">http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/">http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html">http://castleamber.com/testimonials.html

Site Timeline