[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Looking for Webric example code

Dmitri Kondratiev

9/23/2006 5:51:00 PM

I need examples of writing Webric code handling GET and POST requests.
Thanks!
Dima

--
Posted via http://www.ruby-....

8 Answers

James Gray

9/23/2006 6:01:00 PM

0

On Sep 23, 2006, at 12:50 PM, Dmitri Kondratiev wrote:

> I need examples of writing Webric code handling GET and POST requests.
> Thanks!

Google is your friend:

http://www.google.com/search...

See the Hello Servlet example on the first link, or follow the links
on that page to:

http://microjet.ath.cx/webrickguide/html/do_Me...

and:

http://segment7.net/projects/ruby/WEBrick/ser...

James Edward Gray II

Dmitri Kondratiev

9/23/2006 10:07:00 PM

0

Thanks a lot James! This is exactly what I was looking for! (or maybe I
should go to ROR directly, without stoping at WEBrick?...)

James Gray wrote:
> On Sep 23, 2006, at 12:50 PM, Dmitri Kondratiev wrote:
>
>> I need examples of writing Webric code handling GET and POST requests.
>> Thanks!
>
> Google is your friend:
>
> http://www.google.com/search...
>
> See the Hello Servlet example on the first link, or follow the links
> on that page to:
>
> http://microjet.ath.cx/webrickguide/html/do_Me...
>
> and:
>
> http://segment7.net/projects/ruby/WEBrick/ser...
>
> James Edward Gray II


--
Posted via http://www.ruby-....

Mark Firestone

9/23/2006 10:18:00 PM

0

I've had to "upgrade" to 1.8.5, and suddenly PTY is doing weird stuff.
After it looses a connecting, even though I have it in a
begin
rescue
end

sort of structure, it throws an exception and crashes after it exits the
def, throwing an exception

pty - exited: 26825 (PTY::ChildExited)

and bombs, unless i put a rescue structure around the next IO type
operation... I don't understand, this didn't happen in 1.8.1

Please help!

Mark
>
>
>


Marc Heiler

9/24/2006 12:55:00 AM

0

"or maybe I should go to ROR directly, without stoping at WEBrick?"

Depends on what you need. I use Webrick a lot to (among
other things) specify different document roots dynamically, ie
when someone needs a certain file which he cant find on the www but
which is in one of my archives, then a ruby scripts dumps that
file into a temporary dir and starts a special webrick server
for a limited amount of time before cleaning up again.

There are myriads of more different usage examples, my bottom
line would be that it never hurts to have a good look at Webrick
for the stuff YOU could need :)

Btw about the Google thing - I feel that Webrick is underrepresented
on Google as far as up-to-date examples are considered. So google
is NOT always the best solution, i have had recieved more help when
posting specific questions about Webrick in the past too.

--
Posted via http://www.ruby-....

Eleanor McHugh

9/24/2006 9:26:00 PM

0

On 23 Sep 2006, at 23:06, Dmitri Kondratiev wrote:
> Thanks a lot James! This is exactly what I was looking for! (or
> maybe I
> should go to ROR directly, without stoping at WEBrick?...)

WEBrick is very good for writing quick and dirty HTTP servers -
especially if all you want to do is mount some code at a given URL
and return some output nicely wrapped with HTTP headers etc. Writing
complex web applications with vanilla WEBrick is a little more
challenging but can be done however you're probably better off using
RoR, Camping or one of the other frameworks.

Ellie

Eleanor McHugh
Games With Brains
----
raise ArgumentError unless @reality.responds_to? :reason



Dmitri Kondratiev

9/24/2006 9:57:00 PM

0

Eleanor McHugh wrote:
> On 23 Sep 2006, at 23:06, Dmitri Kondratiev wrote:
>> Thanks a lot James! This is exactly what I was looking for! (or
>> maybe I
>> should go to ROR directly, without stoping at WEBrick?...)
>
> WEBrick is very good for writing quick and dirty HTTP servers -
> especially if all you want to do is mount some code at a given URL
> and return some output nicely wrapped with HTTP headers etc. Writing
> complex web applications with vanilla WEBrick is a little more
> challenging but can be done however you're probably better off using
> RoR, Camping or one of the other frameworks.
>
> Ellie
>
> Eleanor McHugh
> Games With Brains
> ----
> raise ArgumentError unless @reality.responds_to? :reason

Thanks for update! I am thinking about using Webric for lightweight
REST-full protocol between WEB peers. In other words I need embedable
WEB server that will allow sevral apps exchange messages using simple
protocol on top of HTTP (get & post + params).
The main question here: can Webric be embeded in another application so
threads of this app will not be blocked and will continue to work
without starvation. In fact, application I am talking about may use
variable number of threads growing from 1 to 100 at different times
(these in addition to Webric threads).


--
Posted via http://www.ruby-....

Eleanor McHugh

9/24/2006 10:53:00 PM

0

On 24 Sep 2006, at 22:57, Dmitri Kondratiev wrote:
> Thanks for update! I am thinking about using Webric for lightweight
> REST-full protocol between WEB peers. In other words I need embedable
> WEB server that will allow sevral apps exchange messages using simple
> protocol on top of HTTP (get & post + params).

I spent several months earlier in the year working on something very
similar (all closed-source unfortunately) and WEBrick provided a good
base.

> The main question here: can Webric be embeded in another
> application so
> threads of this app will not be blocked and will continue to work
> without starvation. In fact, application I am talking about may use
> variable number of threads growing from 1 to 100 at different times
> (these in addition to Webric threads).

Well WEBrick uses its own thread pool and seems to do a pretty good
job of managing it, but they are green threads so you'll have to make
sure that none of the threads in your application are blocking or
else the whole thing will stall. Depending upon your platform and how
computationally intensive your application threads are you may run
into some latency problems, but I doubt this will be the case with
the number of threads in question. If latencies do ocur you might
like to look at using dRb (distributed Ruby) to run some of your
computationally intensive tasks in separate processes.

Ellie


Eleanor McHugh
Games With Brains
----
raise ArgumentError unless @reality.responds_to? :reason



James Britt

9/24/2006 11:54:00 PM

0

Dmitri Kondratiev wrote:
> Thanks a lot James! This is exactly what I was looking for! (or maybe I
> should go to ROR directly, without stoping at WEBrick?...)

You should also look at Nitro, IOWA and Cerise. Each these has a
different approach to Web development, and you might do well to find out
which one best maps to what you want to do.

You can also use Mongrel or Serverside in place of WEBrick; either of
those should give you better performance than WEBrick.

--
James Britt

"A language that doesn't affect the way you think about programming is
not worth knowing."
- A. Perlis