Aredridel
1/29/2005 7:52:00 PM
On Sat, 29 Jan 2005 05:33:29 +0900, Douglas Livingstone
<rampant@gmail.com> wrote:
> > Try just "\n" instead of "\r\n". Since you're on Windows, I think Ruby will
> > output "\r\n" when you use "\n". You may be sending too many newlines.
>
> No joy, but, I have solved it! The working code is:
>
> #!ruby
>
> print "Content-type: text/html\n\n"
> print "<html><body>Hello World!</body></html>\n"
>
> Turns out ruby or apache or something else is sending the 200 for me,
> which is nice :) (though I wonder how to change it then... hmm... back
> to google...)
>
> All that is needed is
>
> print "\n\n"
>
> to get output, though need the text/html for html naturally :)
>
Hehe. You send Status: 200 for setting the status line; you have to
tell Apache that it's an "NPH" CGI if you want to send the HTTP line
yourself.
Also, you use just \n, not \r\n, because you're speaking CGI, not
HTTP. The CGI spec declares that \n is the line ending for headers,
and the web server does the translation.