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

Re: [MacPerl-WebCGI] Re: Document contained no data



Ricky Morse wrote:

> On 20000226.155548, Wolf Alexander Hauser <woffl@gmx.net> wrote:
>
> >I wanted to run the following small perl programm ("demo.pl"):
> >- ---------------------------------------------
> >#!/usr/bin/perl
> >
> >print "Content-type: text/html\n\n";
> >print "Hello, Wold!";
> >- ---------------------------------------------
>
> Hi!  Just a few thoughts....
>
> 1) are you saving the code as a .cgi file?  MacPerl requires that you
> save it in a special format to work on Macs.  However, when you upload it
> to a *nix or Wintel box, you need to upload the .pl file, renaming it to
> .cgi.

Also, make sure that if/when you upload it, that you get the path to perl
right.

>
>
> 2) Mac servers differ from other servers in that they generally don't
> create _any_ headers for .cgi scripts.  So you really need to return
> something like:
>
> $eol = "\015\012";
> print "HTTP/1.0 200 OK", $eol, "Server: WebSTAR 4", $eol, "MIME-Version:
> 1.0", $eol, "Content-type: text/html", $eol, $eol;
>
> This contains all the headers neccesary. (You may be able to use HTTP/1.1
> instead.... read up about the requirements.  Also, change the Server
> field to be whatever server you're using...)

AFAIK, most Mac web servers generally *do* generate headers for the script.
Also, if the CGI is saved as a CGI Script file (which it has to be if it is to
be used on a mac), MacPerl will take care of all of the headers for you. I
suggest you look at the folder "MacPerl CGI" in the MacPerl folder. In
particular, look at the code in Demo.cgi.

Perl:

print "Hello, World!";

Browser gets(on my server):

HTTP/1.0 200 OK
Server: QuidProQuo/2.2
Content-type: text/html
MIME-Version: 1.0

Hello, World!

Perl:

print "Content-type: text/html\n\n";
print "Hello, World!";

Browser gets(on my server):

HTTP/1.0 200 OK
Server: QuidProQuo/2.2
Content-type: text/html
MIME-Version: 1.0

Hello, World!

Perl:

print <<EOF;
HTTP/1.0 200 OK
Server: QuidProQuo/2.2
Content-type: text/html
MIME-Version: 1.0

EOF
print "Hello, World!";

Browser gets(on my server):

HTTP/1.0 200 OK
Server: QuidProQuo/2.2
Content-type: text/html
MIME-Version: 1.0

Hello, World!

>
>
> HTH,
> Ricky




==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org