Forum: Ruby My "Hello World" script is not displaying properly

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
on 2007-02-01 21:50
(Received via mailing list)

I just installed mod_ruby1.2.5 with Apache 2.2.3 on Fedora Core 5
Linux.  Triumphant, I downloaded this test script to my web root

print "HTTP/1.0 200 OK\r\n"
print "Content-type: text/html\r\n\r\n"
print "<html><body>Hello World!</body></html>\r\n"

I restarted my web server but when I load the page in IE, I get

HTTP/1.0 200 OK Content-type: text/html Hello World!

and on Firefox ...

HTTP/1.0 200 OK
Content-type: text/html

<html><body>Hello World!</body></html>

What is wrong?  Below is what I added to my httpd.conf file ...

LoadModule ruby_module /usr/local/apache2/modules/
## On Linux (FC3) this becomes
# LoadModule ruby_module /usr/lib/httpd/modules/

# ClearModuleList
# AddModule mod_ruby.c

<IfModule mod_ruby.c>
  RubyRequire apache/ruby-run

  # Execute files under /ruby as Ruby scripts
  <Location /ruby>
  SetHandler ruby-object
  RubyHandler Apache::RubyRun.instance

  # Execute *.rbx files as Ruby scripts
  <Files *.rbx>
  SetHandler ruby-object
  RubyHandler Apache::RubyRun.instance

Thanks, - Dave
Brian C. (Guest)
on 2007-02-01 22:32
(Received via mailing list)
On Fri, Feb 02, 2007 at 04:50:10AM +0900, removed_email_address@domain.invalid
> What is wrong?

It did what you told it to :-) If you do the following, you should see

  telnet 80
  GET /test.rbx HTTP/1.0
  Host: localhost
  <hit Enter again>

If I'm right, the web server has already output a HTTP/1.0 response, so
script is outputting a second one, which the client sees is not a valid
header, so treats it as the response body.

If you really want your Ruby program to generate the HTTP response,
need to configure your webserver to run it as an nph script. Maybe
it to nph-test.rbx will be sufficient. Otherwise just remove the first
line from your script.


This topic is locked and can not be replied to.