httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey <esote...@3times25.net>
Subject Re: [users@httpd] Help running perl cgi over apache
Date Wed, 18 Feb 2004 11:18:38 GMT
Jonas Eckerman wrote:
> On Tue, 17 Feb 2004 07:49:22 -0500, Geoffrey wrote:
> 
> 
>>>> print "Content-type: text/plain\n\n";
> 
> 
>>> Shouldn't that be \r\n\r\n on a Linux system?
> 
> 
>> No.  \r is a dos thing, it's a wasted character in the UNIX world.
> 
> 
> No, \r is not purely a DOS thing. Some protocols specify CRLF as the
> line termination, regardless of operating system.
> 
> IIRC the HTTP spec says each header line should be terminated by
> CRLF. On a DOS/Windows system \n should result in CRLF and should
> therefore be correct, but on a Linix or Unix system \n shpould result
> in LF wich means you have to specify \r\n to follow the HTTP
> standard.
> 
> If I'm mistaken and the HTTP standard doesn't specify CRLF, then \n
> should be correct on a Unix system but not on a DOS/Windows system.

I'm too busy (or lazy??) to look up the RFC, but personal experience 
indicates it's not necessary on a Linux box.  I have noted that perl CGI 
populates each newline in this way though, so it's likely some truth 
behind it.  But, as I've noted, it does work with Apache on a Linux box 
without it.

It appears you may be correct though as little googling did produce the 
following:

The following is an example CGI program that prints one line to your 
browser. Type in the following, save it to a file called first.pl, and 
put it in your cgi-bin directory.

         #!/usr/bin/perl
         print "Content-type: text/html\r\n\r\n";
         print "Hello, World.";

Even if you are not familiar with Perl, you should be able to see what 
is happening here. The first line tells Apache (or whatever shell you 
happen to be running under) that this program can be executed by feeding 
the file to the interpreter found at the location /usr/bin/perl. The 
second line prints the content-type declaration we talked about, 
followed by two carriage-return newline pairs. This puts a blank line 
after the header, to indicate the end of the HTTP headers, and the 
beginning of the body. The third line prints the string ``Hello, 
World.'' And that's the end of it.

-- 
Until later, Geoffrey                     Registered Linux User #108567
Building secure systems inspite of Microsoft


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message