• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Return a document

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
Lee5
Asked:
Lee5
  • 2
  • 2
1 Solution
 
hutterCommented:
Try

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

0
 
Lee5Author Commented:
The statement:
print "Location: $url\n\n";
prints out the value of $url
Also, can't find any reference to the tag "Location"
0
 
hutterCommented:
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
 
Lee5Author Commented:
You are right
I had a print context type at the top of the page.
thanks for the help

0
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

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now