Looking for Webric example code

D

Dmitri Kondratiev

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

Dmitri Kondratiev

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

Mark Firestone

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
 
M

Marc Heiler

"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.
 
E

Eleanor McHugh

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
 
D

Dmitri Kondratiev

Eleanor said:
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

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).
 
E

Eleanor McHugh

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
 
J

James Britt

Dmitri said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,213
Messages
2,571,106
Members
47,699
Latest member
lovelybaghel

Latest Threads

Top