[MacRuby] Simple embedded WEBrick?
Hello, I am new to MacRuby, and new to this list, so first a "Hello"! Secondly, I am trying to start a simple WEBrick in a Ruby App. The WEBrick code is a sample from a book, and runs fine if started on its own. But when I evaluate the file in MacRuby within my Cocoa App, a call to http://localhost:2000/hello yields "Bad Request". Furthermore (as to be expected), the script does not return. I am happy creating a separate thread for the Ruby Evaluation in my Cocoa App, but is there a better way? My sample project is hosted here: http://github.com/below/RubyTest I would be very thankful if someone could have a look (and I am sure others will find this useful information, too) Thanks a lot! Alex
Hi! Welcome to the MacRuby world ;-). I imagine you are running MacRuby 0.5 on your machine, seeing the paths you include in your .rb file? Why are you doing all those includes by the way? All the necessary paths will be in MacRuby's default path. As for the "Bad Request", do you get any error log or anything? I cannot reproduce here because webrick is broken with current trunk: /Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/1.9.0/webrick/httpauth/htpasswd.rb:38: regexp `:{SHA} 'compilation error: U_REGEX_BAD_INTERVAL 2010-04-27 11:30:40.648 RubyTest[38472:5807] SyntaxError: /private/tmp/RubyTest/build/Debug/(eval):17:in `<main>': compile error (SyntaxError) I don't know what is our take on fixing webrick but the current problem is that our Regex library doesn't know the {SHA} regex rule. Maybe we can add it? I don't know, Laurent or Vincent would know better than me on that one :-). As for running the script, it depends on what you intend to do with it actually. The solution would depend on the end usage :-) -- Thibault Martin-Lagardette On Apr 27, 2010, at 06:34, Alexander von Below wrote:
Hello,
I am new to MacRuby, and new to this list, so first a "Hello"!
Secondly, I am trying to start a simple WEBrick in a Ruby App. The WEBrick code is a sample from a book, and runs fine if started on its own.
But when I evaluate the file in MacRuby within my Cocoa App, a call to http://localhost:2000/hello yields "Bad Request".
Furthermore (as to be expected), the script does not return. I am happy creating a separate thread for the Ruby Evaluation in my Cocoa App, but is there a better way?
My sample project is hosted here: http://github.com/below/RubyTest
I would be very thankful if someone could have a look (and I am sure others will find this useful information, too)
Thanks a lot!
Alex _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Am 27.04.2010 um 20:42 schrieb Thibault Martin-Lagardette:
Welcome to the MacRuby world ;-).
Thanks a lot!
I imagine you are running MacRuby 0.5 on your machine, seeing the paths you include in your .rb file? Why are you doing all those includes by the way? All the necessary paths will be in MacRuby's default path.
I was trying to find my mistake, and looked at a friends code .... so, to be honest, I have no idea why I include them (His code is here: http://github.com/jfahrenkrug/MacRubyRemote)
As for the "Bad Request", do you get any error log or anything?
Only: [2010-04-27 22:46:31] INFO WEBrick::HTTPServer#start: pid=574 port=2000 [2010-04-27 22:46:33] ERROR bad Request-Line `GET /hello HTTP/1.1 '. localhost - - [27/Apr/2010:22:46:33 CEST] "GET /hello HTTP/1.1 " 400 304 - ->
As for running the script, it depends on what you intend to do with it actually. The solution would depend on the end usage :-)
Here is, what I really want: We need a very simple web server for our Cocoa Project. I am pretty new to Ruby, but whenever I need to test a webservice or somthing like that, I whip up a little WEBrick. But running it as a seperate task would mean I would have to establish some sort of Inter Process Communication (IPC) But the main app is ObjC, and should remain ObjC (because I am a much better ObjC Coder than Ruby Coder). So I thought, I could run the WEBrick embedded with MacRuby and solve all my problems. But now that all my attempts to run the WEBrick in embedded MacRuby failed, maybe I need other options. I might try Distributed Objects, does that work in MacRuby? But the preferred way still would be to host the WEBrink embedded in the ObjC/Cocoa app. Thanks a lot Alex
Am 27.04.2010 um 20:42 schrieb Thibault Martin-Lagardette:
Hi!
Welcome to the MacRuby world ;-).
I imagine you are running MacRuby 0.5 on your machine, seeing the paths you include in your .rb file? Why are you doing all those includes by the way? All the necessary paths will be in MacRuby's default path.
If I leave out the "include orgy", I get an error: 2010-05-03 21:58:57.384 Procuratio Menu Server[12756:5f07] LoadError: no such file to load -- webrick Alex
On Apr 27, 2010, at 06:34, Alexander von Below wrote:
Hello,
I am new to MacRuby, and new to this list, so first a "Hello"!
Secondly, I am trying to start a simple WEBrick in a Ruby App. The WEBrick code is a sample from a book, and runs fine if started on its own.
But when I evaluate the file in MacRuby within my Cocoa App, a call to http://localhost:2000/hello yields "Bad Request".
Furthermore (as to be expected), the script does not return. I am happy creating a separate thread for the Ruby Evaluation in my Cocoa App, but is there a better way?
My sample project is hosted here: http://github.com/below/RubyTest
I would be very thankful if someone could have a look (and I am sure others will find this useful information, too)
Thanks a lot!
Alex _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (2)
-
Alexander von Below
-
Thibault Martin-Lagardette