Class: WebrickServletCGIwrapper

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Includes:
CGI::QueryExtension
Defined in:
lib/lapillus/webrick_server.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, *options) ⇒ WebrickServletCGIwrapper

Returns a new instance of WebrickServletCGIwrapper.



37
38
39
40
41
# File 'lib/lapillus/webrick_server.rb', line 37

def initialize(server,*options)
#      puts "initialize(#{server},#{options.to_yaml}) called"
  super(server,*options)
  @env=Hash.new # remove?
end

Instance Method Details

#env_tableObject



47
48
49
# File 'lib/lapillus/webrick_server.rb', line 47

def env_table
  @env
end

#out(options = "text/html") ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/lapillus/webrick_server.rb', line 51

def out(options = "text/html")
#      puts "out(#{options.to_yaml} called"
#      puts "@output_cookies #{@output_cookies.to_yaml}"
  
  options = { "type" => options } if options.kind_of?(String)
  content = yield
  
  @res.body = content
  options.each{|key,val| @res[key]=val }
  @res.cookies.concat(@output_cookies)
end

#service(req, res) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/lapillus/webrick_server.rb', line 64

def service(req, res)
  @res=res
  @env = req.meta_vars.clone
  @env.delete "SCRIPT_NAME"
  @env["QUERY_STRING"] = req.request_uri.query
  @env["REQUEST_URI"]  = req.request_uri

  @stdin=StringIO.new(req.body || "")
  initialize_query()
  
  Dispatcher.dispatch(self,@options[0])
end

#stdinputObject



43
44
45
# File 'lib/lapillus/webrick_server.rb', line 43

def stdinput
  @stdin || $stdin # remove || $stdin
end