Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

outputting HTML from REBOL cgi script

 [1/8] from: peoyli::algonet::se at: 20-Feb-2001 13:46


Hi, I got a strange problem while experimenting with REBOL CGI's.... The problem occurs with both version 2.3 and the latest experimental version of core (2.4.40.1.1) It seems like REBOL is adding its own 'Content-type' header, so that all REBOL CGI script output is text/plain (and therefor is useless for HTML output).. Perl cgi's work fine, so I doubt my server configuration is incorrect. If I telnet to the web server and manually enters the request, I get the following: bash-2.03$ telnet 172.16.0.3 80 Trying 172.16.0.3... Connected to 172.16.0.3. Escape character is '^]'. GET /frida-molle/showpic.cgi?pic=3 HTTP/1.0 HTTP/1.1 200 OK Date: Tue, 20 Feb 2001 13:29:33 GMT Server: Apache/1.3.14 (AMIGA) PHP/4.0.4 PHP/4.0.4 Content-Type: text/html Connection: close Content-Type: text/plain <HTML> <HEAD> <TITLE> ..... ... The first content-type is the one I have in the script, and the second seems to come from REBOL itself. Very minimal script to reproduce the problem: --- #!/usr/local/bin/rebol --cgi REBOL [ Title: "CGI test script" ] print "Content-Type: text/html^/^/" print { <HTML><HEAD><TITLE>Just testing</TITLE></HEAD> <BODY BGCOLOR="white"> Just testing, minimal REBOL cgi script </BODY> </HTML> } --- and the manual HTTP request I send through telnet: GET /frida-molle/test-cgi.cgi HTTP/1.0 HTTP/1.1 200 OK Date: Tue, 20 Feb 2001 13:38:48 GMT Server: Apache/1.3.14 (AMIGA) PHP/4.0.4 PHP/4.0.4 Content-Type: text/html Connection: close Content-Type: text/plain ... If I on the other site tries to access a page that do not exist, I get: GET /nonexistant-page.txt HTTP/1.0 HTTP/1.1 404 Not Found Date: Tue, 20 Feb 2001 13:40:30 GMT Server: Apache/1.3.14 (AMIGA) PHP/4.0.4 PHP/4.0.4 Connection: close Content-Type: text/html; charset=iso-8859-1 ... So.. where's the problem ? /PeO -- /* PeO - AMiGA owner since 1990, CGI, Perl, Assembly language & HTML-fanatic *\ \* Amiga 4000TE/060-50/604e 200, 146Mb, 33.4Gb, ZIP, JAZ, CVPPC/8 */ /* IIyama VM Pro 21", CP-SW2 Subwoofer system, NEC-222 *\ \* Plextor 12-Plex, Yamaha CRW 4416S, Artec A6000C+, Stylus Color 500 */ /* Lightfax 3660, Catweazel Z-II (3*IDE, 1*PC Floppy), Minolta DImage V *\ \* SCSI-Tower, Seagate Tapestor 4/8GB, Ariadne Ethernet, Minolta PagePro 6 */

 [2/8] from: gjones05:mail:orion at: 20-Feb-2001 7:23


Hi, P-O, For what its worth, I tried your minimal test script on my Win98, Apache 1.3.14, RBOL/Core 2.3.0.3.1 local testbed, and it worked fine. So there seems to be some sort of problem more specific to your platform and/or set up. I doubt that this is the problem but only one additional newline is needed, since 'print already supplies one. Again, this won't seem to be the likely cause. Perhaps an Amigan-Apache-REBOLer could test your script. Good luck. --Scott

 [3/8] from: gjones05:mail:orion at: 20-Feb-2001 7:44


Whoops, I forgot to add the code:
<snip> > I doubt that this is the problem but only one additional > newline is needed, since 'print already supplies one. > --Scott
print "Content-Type: text/html^/" is satisfactory instead of: print "Content-Type: text/html^/^/" --Scott

 [4/8] from: peoyli:algonet:se at: 20-Feb-2001 15:52


Did not make any difference.. I still get double Content-type headers.. A perl script that does exactly the same thing works without problems: --- #!/usr/local/bin/perl print "Content-type: text/html\n\n"; print <<EOM; <HTML><HEAD><TITLE>Just testing</TITLE></HEAD> <BODY BGCOLOR="white"> Just testing, minimal Perl cgi script </BODY> </HTML> EOM --- .. and is also 3 lines smaller ..and actually.. no extra newlines after the header is enough, since 'print on the next line also gives one.. /PeO

 [5/8] from: holger:rebol at: 20-Feb-2001 15:43


On Tue, Feb 20, 2001 at 07:44:18AM -0600, GS Jones wrote:
> print "Content-Type: text/html^/"
Try changing this to prin ["Content-Type: text/html" crlf crlf] The HTTP standard requires CRLF as the separator, not just LF. Apache probably does not convert this by itself. -- Holger Kruse [holger--rebol--com]

 [6/8] from: gjones05:mail:orion at: 20-Feb-2001 18:34


From: "Holger Kruse"
> prin ["Content-Type: text/html" crlf crlf] > > The HTTP standard requires CRLF as the separator, not just LF. Apache > probably does not convert this by itself.
I guess that the ^/ is converted to a carriage return linefeed on Windows REBOL, accounting for the difference in platforms. Thanks, Holger. --Scott

 [7/8] from: gjones05:mail:orion at: 21-Feb-2001 2:55


From: "GS Jones" <[gjones05--mail--orion--org]>
> From: "Holger Kruse" > > prin ["Content-Type: text/html" crlf crlf] > > > > The HTTP standard requires CRLF as the separator, not just LF.
Apache
> > probably does not convert this by itself. > > I guess that the ^/ is converted to a carriage return linefeed on > Windows REBOL, accounting for the difference in platforms. Thanks, > Holger. > --Scott
It just occurred to me that my scripts running on Apache on Solaris have run fine with print "Content-Type: text/html^/" For what its worth, -Scott

 [8/8] from: peoyli:algonet:se at: 21-Feb-2001 10:26


Still the same problem: ... prin ["Content-Type: text/html" crlf crlf] print { ... and a resulting HTTP request produces (haven't tested it anymore in the browser, because of the result I got through a telnet-test): Date: Wed, 21 Feb 2001 10:23:52 GMT Server: Apache/1.3.14 (AMIGA) PHP/4.0.4 PHP/4.0.4 Content-Type: text/html Connection: close Content-Type: text/plain /PeO