kiss9815 / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Ruby anyone? #344

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I posted earlier regarding a problem I was having with Ruby.  I've made some 
progress, but now it seems like I'm having some kind of issue between Ruby and 
Mongoose at the CGI level.  Here's a summary:

First -- I am using SuSE 12.1 64-bit Intel

Second -- my mongoose.conf:

document_root  /home/andy/mongoose/ccweb
cgi_interpreter "/home/andy/.rvm/rubies/ruby-1.9.2-p318/bin/ruby"
cgi_pattern **.rb$
listening_ports 8000
index_files index,home

Third, my index.rb:

#!/home/andy/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
print "HTTP/1.1 200 OK\r\n"
print "Content-type: text/html\r\n\r\n"; 
print "<html><body>Hello World!</body></html>\r\n\r\n"  

When I hit the URL (http://localhost:8000/index.rb), I get this:

Error 500: Internal Server Error
CGI program sent malformed HTTP headers: []

STRANGELY, though, I get this in my error.log and access.log, respectively:

[1334185458] [error] [client 127.0.0.1] GET /index.rb: Error 500: Internal 
Server Error

127.0.0.1 - - [11/Apr/2012:16:04:18 -0700] "GET /index.rb HTTP/1.1" 200 76 - 
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) 
Chrome/17.0.963.83 Safari/535.11"

According to the error log, I am getting an internal server error, yet the access log shows a successful response (Code 200 - OK).

Let me step back a bit -- I've done a lot of searching of the internet in order to resolve these problems. I'm not thoroughly convinced that anyone has ever used Ruby with Mongoose. As such, I am curious to know if anyone reading this message has ever been successful using these two technologies combined. I'm about to abandon Ruby for PHP, but I'd prefer not because I find Ruby much more powerful.

Any suggestions would be helpful. Thank you! -Andy


Original issue reported on code.google.com by `ananon...@gmail.com` on 11 Apr 2012 at 11:35
GoogleCodeExporter commented 9 years ago
Your example works for me with different interpreter line:

$ cat a.rb
#!/usr/bin/env ruby

print "HTTP/1.1 200 OK\r\n"
print "Content-type: text/html\r\n\r\n"; 
print "<html><body>Hello World!</body></html>\r\n\r\n"
$ chmod 755 a.rb
$ mongoose -cgi_pattern **.rb$

I can see hello world message.

Please make sure you can run your script from shell, i.e.
$ ./a.rb

I should not give any error.

Original comment by valenok on 9 May 2012 at 9:14

GoogleCodeExporter commented 9 years ago

Original comment by valenok on 6 Jun 2012 at 6:05

GoogleCodeExporter commented 9 years ago
I've been away on contract and haven't had much free time.  I'll try your 
recommendation and get back to you within one week.

Original comment by ananon...@gmail.com on 6 Jun 2012 at 5:31