Ruby Cgi Puzzle on Apache

Hi, All,

     On my Linux machine, I configured Mod_fcgid.2.0 in Apache2.2.3. 

And
I also installed ruby-1.8.5. Then I wrote two .rb files in the Apache
cgi-bin directory, as follows.
//////////////////////cgitest01.rb starts/////////////////////
#!/usr/local/bin/ruby
puts “”;
puts “nice prog!”;
//////////////////////cgitest01.rb ends//////////////////////
//////////////////////cgitest02.rb starts/////////////////////
#!/usr/local/bin/ruby
puts “nice prog!”;
//////////////////////cgitest02.rb ends/////////////////////
At this moment I visited
http://xx.yyy.com/cgi-bin/cgitest01.rb,
and it worked well. It printed out “nice prog!” normally.
However, when I visited
http://ts.cn.oracle.com/cgi-bin/cgitest02.rb, I got the following error:
[Wed Nov 08 17:18:26 2006] [error] [client 146.56.236.149] malformed
header
from script. Bad header=nice prog!: cgitest02.rb

Anybody can tell me why I encountered the error when visiting
cgitest02.rb?
Why must I put out an empty line (puts “”:wink: at the biginning of the file
if
I want to successfully visit it?

Many Thanks in advance!

Rgds,
Shiwei

shiwei zhang wrote:

//////////////////////cgitest02.rb starts/////////////////////
Anybody can tell me why I encountered the error when visiting cgitest02.rb?
Why must I put out an empty line (puts “”:wink: at the biginning of the file if
I want to successfully visit it?

Many Thanks in advance!

Rgds,
Shiwei

You Have To Because That’s How HTTP Works.

Read up on the format of HTTP requests and replies, it will do you a
load of good. For the abridged version, a HTTP request or reply consist
of a sequence of headers, one per line (AFAIK), a blank line, and the
body.

The blank line is part of the HTTP syntax which indicates that headers
end. (And for a GET request, that the request ends.)

David V.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs