view · edit · sidebar · attach · print · history




  • port sbsm/ to use the rack webserver
  • Keep in Mind



port sbsm/ to use the rack webserver

SBSM has not test code for stuff like cookies, redirect, passthru, remote_host. Looking whether it is easy to add tests for these points. returns the following cookies (name, value, path, domain, expiration date)

  _session_id     408e56abd4f72a9c694762e356b09da8        /    End Of Session
  sbsm-persistent-cookie  language%3Den   /    10.10.2026, 08:35:321

Okay. The old apache config for mod_ruby contained a definition of RubyTransHandler Steinwies::TransHandler.instance. This is missing now. In the source code of mod_ruby I find the lines

    AP_INIT_TAKE1("RubyTransHandler", ruby_cmd_trans_handler, NULL, OR_ALL,
     "set translation handler object"),
  static int ruby_trans_handler(request_rec *r)                               
    ruby_dir_config *dconf = get_dir_config(r);                           

    return ruby_handler(r, dconf->ruby_trans_handler, NULL,              
                        rb_intern("translate_uri"), 0, 0);          

This is used to translate the uri. Adapted to use the following parameters def initialize(drb_uri, trans_handler, env, html_version = "html4"). I think this is much clearer. Also added the following lines at the beginning of sbsm/request/process

        file_name = File.expand_path(File.join('doc', @request.path))
        if File.file?(file_name)
          if /css/i.match(File.basename(file_name))
            @response.set_header('Content-Type', 'text/css')
            @response.set_header('Content-Type', 'text/plain')
          @response.write(, File::RDONLY){|file|})
          return @response

The hard coded value of doc must still be replaced by a configuration value (or at least be possible to override). Also creating a file (instead of the doc/index.rbx) to start the WebServer. Content is

  #!/usr/bin/env ruby
  require 'sbsm/request'
  lib_dir = File.expand_path(File.join(File.dirname(__FILE__), 'src').untaint)
  $LOAD_PATH << lib_dir
  require 'util/app'
  # DRb.start_service('druby://localhost:0')

  require 'rack'
  require 'rack/show_exceptions'

    :app =>,
    :Port => 9292,

Now the steinwie page displays correctly the home page, but navigation to a sub page always displays the home page. This must be correct.

Nota bene: Webserver is now being started using sudo -u apache /usr/local/bin/bundle exec rackup

Tried half an hour to use the rack-test gem to test sbsm. But it proved not so easy. Must begin again another time with a fresh mind.

Search a long time on where to add calls to the translate_uri. It still does not work and somehow wants to got from -> Looks like the servername is not get set correctly. This was fixed by changing the line server_name: in etc/config.yaml. But we still do display the correct site, eg. still has the same content as Will fix this next week.

Saved my changes in the rack branches with commits:

Just stumbled via Ruby weekly on an article to build a Rack webserver in ruby. See

view · edit · sidebar · attach · print · history
Page last modified on October 13, 2016, at 10:16 AM