Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Return a document

Posted on 1998-10-13
4
Medium Priority
?
169 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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
Suggested Courses

810 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