Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Location doesn't work on MAC

by Anonymous Monk
on Apr 13, 2001 at 22:03 UTC ( [id://72415]=perlquestion: print w/replies, xml ) Need Help??

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

I use Location to redirect. It doesn't work on MAC. What's the problem and how to solve it? Thanks a lot.

Replies are listed 'Best First'.
Re: Location doesn't work on MAC
by converter (Priest) on Apr 13, 2001 at 22:32 UTC

    Fist, some (hopefully) constructive criticism of your post:

    • It's usually a good idea to include example code to demonstrate how you're attempting to do something. If there's a flaw in your methods we can tell you how to correct them.
    • It's also a good idea to explain how something is not working. Often, something that is described as "not working" is just not working like you expected it to.

    Since you didn't explain the how, I'll assume that you're just printing the Location header. This may work fine with some browsers, but if I remember correctly, the standard is to include a Status: 302 msg, and some browsers may not handle a Location header without the status message (this is from foggy memory).

    You should be using CGI to parse queries and handle headers. Here's an example of the output of CGI's redirect() method:

    $ perl -MCGI=:standard -e 'print redirect("http://foo")' (offline mode: enter name=value pairs on standard input) Status: 302 Moved Location: http://foo

    To do this in your program:

    use CGI qw/:standard/; print redirect("http://foo");

    Hope this helps.

    Update:

    Minor correction (...without the status message)

Re: Location doesn't work on MAC
by Asim (Hermit) on Apr 13, 2001 at 22:40 UTC

    I could use a lot more information here. Which browser (including version number) are you using? Does it work on PC-based browsers? Are you getting an error? Where are you trying to go? And you certain you're using the correct header style (HINT: it's much easier to do this with CGI.pm, which provides a redirect method for you.)

    You could start with this FAQ node, or the answers to a similar problem. Or just use the search function, and search for redirect. Heck, that's how I found the above two nodes. There's a good bit on general help with CGI in Perl here, too.

    If none of that helps, come back with the details (what your header looks like, browser/platform/webserver details, and exact error message), and post a reply to this message.

    ----Asim, known to some as Woodrow.

Re: Location doesn't work on MAC
by sachmet (Scribe) on Apr 13, 2001 at 22:23 UTC
    Do you have a code sample you could show?

    Generally, it should just be:
    print qq#Location: $newlocation\n\n#; exit(0);
    and that should work. I've never had a problem handing that off to people using Macs...

    The other thing you could try is sending back a HTML document with a meta-refresh tag, and a link in case the refresh doesn't occur.
      The other thing you could try is sending back a HTML document with a meta-refresh tag, and a link in case the refresh doesn't occur.
      No. Please don't. It kills the use of my "back" button, because I press back, it goes to the meta-refresh doc, and then refreshes forward again.

      If you can at all generate headers, the headers method is much preferred.

      -- Randal L. Schwartz, Perl hacker

        While I agree with merlyn (i.e. don't use the meta-refresh tag), at least specify that the page is to redirect after 5 seconds. This should give plenty of time to hit the back button twice. I don't remember the specific syntax for this but i believe the tag would look like this:
        <meta http-equiv="Refresh" content="5;http://url-goes-here">

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-16 19:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found