Looking for Webric example code

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

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

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

Google is your friend:

http://www.google.com/search?q=webrick

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

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

and:

http://segment7.net/projects/ruby/WEBrick/servlets.html

James Edward G. II

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 G. wrote:

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

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

Google is your friend:

http://www.google.com/search?q=webrick

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

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

and:

http://segment7.net/projects/ruby/WEBrick/servlets.html

James Edward G. II

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

“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 :slight_smile:

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.

On 23 Sep 2006, at 23:06, Dmitri K. 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

Eleanor McHugh wrote:

On 23 Sep 2006, at 23:06, Dmitri K. 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).

On 24 Sep 2006, at 22:57, Dmitri K. 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

Dmitri K. 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 B.

“A language that doesn’t affect the way you think about programming is
not worth knowing.”

  • A. Perlis

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