Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Webrick & HOWTO type docs?

Reply
Thread Tools

Webrick & HOWTO type docs?

 
 
Kirk Haines
Guest
Posts: n/a
 
      05-24-2004
I think I know the answer to this already, but....

Are there any not-so-easy-to-find documents anywhere on using Webrick? API
docs or howto docs or anything like that?

I'm going to make Iowa capable of using webrick so that an Iowa application
can be a completely standalone application server. From what I can tell,
this graft looks like it should be an extremely simple one, but I haven't
been able to find a lot of documentation so I'm mostly going to be working
from looking at the webrick code and at other pieces of software that use
it, unless someone can point me to something that I have missed.

If there is nothing, then I will try to document what I learn while I go
about this project as a way to start making some practical HOWTO type
documentation available for webrick.


Thanks,

Kirk Haines



 
Reply With Quote
 
 
 
 
Kirk Haines
Guest
Posts: n/a
 
      05-24-2004
On Mon, 24 May 2004 13:34:01 -0700, Eric Hodel wrote
> To mount the servlet:
>
> server = WEBrick::HTTPServer.new
> server.mount "/some/path", MyServlet, any_extra_args


Thanks, Eric. I have two questions about the servlet architecture:

1) Can the code that executes the server.mount() dynamically alter the mount
points? i.e. when a configuration file changes either add to or remove
mount points?

2) What if a person has a list of a couple hundred URLs that they want
mounted to the servlet? Will that be ugly with Webrick, or no problem?


Thanks much,

Kirk Haines



 
Reply With Quote
 
 
 
 
Michael Neumann
Guest
Posts: n/a
 
      05-24-2004
--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, May 25, 2004 at 05:12:24AM +0900, Kirk Haines wrote:
> I think I know the answer to this already, but....
>
> Are there any not-so-easy-to-find documents anywhere on using Webrick? API
> docs or howto docs or anything like that?
>
> I'm going to make Iowa capable of using webrick so that an Iowa application
> can be a completely standalone application server. From what I can tell,


I wrote such a thing for Iowa 0.14a (it's appended). Don't know if it still works with
the current Iowa release.

Regards,

Michael

--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="webrick-adaptor.rb"

require 'webrick'
require "socket"
require "iowa/config"

class IOWAServlet < WEBrick::HTTPServlet::AbstractServlet
def service(req, res)
url, = req.request_uri.to_s.split("?")
params = if req.request_method == "GET"
req.query_string || ""
else
req.body
end

url =~ ".*?/iowa/([^/]*)"
socket_name = "#{$tempDir}iowa_#{$1}"
socket = UNIXSocket.new(socket_name)
socket.putc(url.length)
socket.write(url)
socket.putc(params.length)
socket.write(params)
socket.shutdown(1)

body = ""
while (recv = socket.recv(1000)) != "" do
body << recv
end

res['Content-type'] = "text/html"
res.body = body
end
end

if __FILE__ == $0
s = WEBrick::HTTPServer.new(
ort => 2000,
ocumentRoot => '/home/michael/htdocs',
:Logger => WEBrick::Log::new($stderr, WEBrick::Log:EBUG)
)

s.mount("/iowa", IOWAServlet)
trap("INT"){ s.shutdown }
s.start
end

--cWoXeonUoKmBZSoM--


 
Reply With Quote
 
Kirk Haines
Guest
Posts: n/a
 
      05-24-2004
On Tue, 25 May 2004 05:48:09 +0900, Michael Neumann wrote

> I wrote such a thing for Iowa 0.14a (it's appended). Don't know if
> it still works with the current Iowa release.


Cool. It won't work with the current release, but it should help give me a
push in the right direction. Thank you very much.

Kirk Haines



 
Reply With Quote
 
Kirk Haines
Guest
Posts: n/a
 
      05-24-2004
On Mon, 24 May 2004 14:24:50 -0700, Eric Hodel wrote

> These two questions tell me you have one instance that handles many
> URLs. Instead of handling this in WEBrick, create a servlet that
> handles one level up, and add a dispatcher to it (or inside IOWA, if
> you already have one written).
>
> (Instead of mounting /foo/bar and /foo/baz, mount a servlet at /foo.)


What I would like to replicate is basically how I have it working with my
mod_ruby handler under Apache.

Basically, I have a list of paths. IF a request matches one of the paths in
the list, the request goes to Iowa for handling. If not, then it gets
handled by the web server. So, really, I want to mount /, but then
selectively fall through to let something other than the servlet handle the
request.

If I can do this, then with the ability of Webrick to serve regular content,
an entire application can be handled, along with graphics or static files,
from Webrick. It will make it _extremely_ easy to bring an Iowa application
up.


Thanks,

Kirk Haines



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WEBrick: Has anyone used WEBrick::Session? Lloyd Zusman Ruby 2 02-21-2013 06:49 PM
WEBrick::Daemon and WEBrick Aaron Smith Ruby 2 03-18-2007 03:47 AM
[WEBrick] howto rewrite url Simon Strandgaard Ruby 5 12-02-2004 07:28 PM
Webrick URIs to autosearch extension sequence (eg. html, htm, pdf) Howto? Ralph Amissah Ruby 0 01-30-2004 01:25 PM
HowTo Send Uploaded File with INPUT Type file to Sql Server Image Data Type Roberto ASP General 3 10-18-2003 06:56 AM



Advertisments