Solved

Does LOCATION: http://  Work?

Posted on 1997-11-12
6
161 Views
Last Modified: 2013-12-25
I am using the following line in my CGI-PERL code:

print "Location: http://mywebsite.com/test.htm\n\n";

This is the ONLY line I have that outputs back to browser.  From what I've gathered, this should tell the browser to switch to this new web site (mywebsite.com/test.htm).  Unfortunately it doesn't do this.  

All I get is DOCUMENT CONTAINS NO DATA (or something to that extent) by Netscape 4.0 and down and MS Explorer.

Any clues as to what I'm doing wrong?
0
Comment
Question by:jujoo
  • 3
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1831153
Perhaps the http://mywebsite.com/test.htm document contains no data?
Or perhaps some other line in your program is preventing the only output line from printing.
0
 
LVL 3

Accepted Solution

by:
gwalters earned 0 total points
ID: 1831154
One more newline ought to do it (an HTTP header is delimited by a blank line).

BTW, I hope you're planning on increasing the points before grading this.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1831155
Funny, looks like there's a blank line after the Location header to me...

jujoo, if you run the script from the commasd line what does it print? That might tell you something.
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 3

Expert Comment

by:gwalters
ID: 1831156
Oops, I didn't look closely enough.  Now that I have, I see the real problem.  Try printing this:


"Location: http://mywebsite.com/test.htm\r\n\r\n"



You MUST use CR LF at the end of lines in HTTP.


0
 
LVL 6

Expert Comment

by:alamo
ID: 1831157
Must? I have never used \r\n and have seen only a handful of examples which do, almost everything I've seen uses just \n. I've never had a problem. (The server is repsonsible for parsing the headers anyway). Is this server-dependent?
0
 
LVL 3

Expert Comment

by:gwalters
ID: 1831158
OK, "must" (especially with my all-caps emphasis) might have been a bit strong.  I meant it was in the HTTP spec as CR LF.

I beleive most servers see the LF coming in from a CGI and convert them to CR LF.

Could we get a URL to check so we can stop guessing here (and I can stop making bold statements that turn out to be wrong ;)


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question