Solved

Return a document

Posted on 1998-10-13
4
152 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now