[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Is binmode needed in MacPerl?



Jamie McCarthy <jamie@voyager.net> writes:
>>#!perl
>>open(GIF, ":Images:picture.gif") || die "oops!\n";
>>
>>print "HTTP/1.0 200 OK";
>>print "Server: MacHTTP";
>>print "MIME-Version: 1.0";
>>print "Content-type: image/gif";
>
>First of all, CGIs don't send the HTTP status in return;  you start with 
>the headers and trust the server to send the 200.  I don't know about 
>those "Server:" and "MIME-Version:" headers -- it might work with them, 
>but they're unnecessary.

This is not strictly true on the Mac. The PCGI glue accepts both simple headers
(as in the UNIX CGI spec and complete headers as required by MacHTTP (or the
UNIX nph (Non-parsed headers) CGI spec). However, you need to terminate your
lines, preferably with

$crlf = "\015\012";

print "HTTP/1.0 200 OK$crlf";

Matthias

-----
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "I'm set free to find a new illusion" -- Velvet Underground