?
Solved

Return a document

Posted on 1998-10-13
4
Medium Priority
?
171 Views
Last Modified: 2010-03-05
How can I have a perl script return a document to the browser.  For example a .txt file or a .doc file.  Some of the documents contain html tags, so I can't just print them back.  It needs to be something like the the response to http://www.aaa.com/doc.txt
0
Comment
Question by:Lee5
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:hutter
ID: 1205324
Try

$some_url = "http://www.aaa.com/doc.txt";
print "Location: $some_url\n\n";

0
 

Author Comment

by:Lee5
ID: 1205325
The statement:
print "Location: $url\n\n";
prints out the value of $url
Also, can't find any reference to the tag "Location"
0
 
LVL 1

Accepted Solution

by:
hutter earned 200 total points
ID: 1205326
The
print "Location: $url\n\n";
(two line breaks !!)
must be the first output to the browser.
It works perfectly.

A reference for Location: can be found in RFC 2068, e.g. at
http://www.w3.org/Protocols/rfc2068/rfc2068

Let me quote:

14.30 Location

   The Location response-header field is used to redirect the recipient
   to a location other than the Request-URI for completion of the
   request or identification of a new resource. For 201 (Created)
   responses, the Location is that of the new resource which was created
   by the request.  For 3xx responses, the location SHOULD indicate the
   server's preferred URL for automatic redirection to the resource. The
   field value consists of a single absolute URL.

          Location       = "Location" ":" absoluteURI

   An example is

          Location: http://www.w3.org/pub/WWW/People.html

     Note: The Content-Location header field (section 14.15) differs
     from Location in that the Content-Location identifies the original
     location of the entity enclosed in the request. It is therefore
     possible for a response to contain header fields for both Location
     and Content-Location. Also see section 13.10 for cache requirements
     of some methods.
0
 

Author Comment

by:Lee5
ID: 1205327
You are right
I had a print context type at the top of the page.
thanks for the help

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

589 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