lib/rack/handler/mongrel2.rb in rack-mongrel2-0.1.0 vs lib/rack/handler/mongrel2.rb in rack-mongrel2-0.1.1
- old
+ new
@@ -14,13 +14,16 @@
raise ArgumentError.new('Must specify an :uuid or set RACK_MONGREL2_UUID') if options[:uuid].nil?
conn = ::Mongrel2::Connection.new(options[:uuid], options[:recv], options[:send])
running = true
- trap('SIGINT') do
- running = false
- conn.close
+
+ # This doesn't work at all for some reason
+ %w(INT TERM).each do |sig|
+ trap(sig) do
+ running = false
+ end
end
while running
req = conn.recv
next if req.disconnect?
@@ -37,16 +40,16 @@
'rack.run_once' => false,
'mongrel2.pattern' => req.headers['PATTERN'],
'REQUEST_METHOD' => req.headers['METHOD'],
'SCRIPT_NAME' => script_name,
'PATH_INFO' => req.headers['PATH'].gsub(script_name, ''),
- 'QUERY_STRING' => req.headers['QUERY']
+ 'QUERY_STRING' => req.headers['QUERY'] || ''
}
env['SERVER_NAME'], env['SERVER_PORT'] = req.headers['host'].split(':', 2)
req.headers.each do |key, val|
unless key =~ /content_(type|length)/i
- key = "HTTP_#{key.upcase}"
+ key = "HTTP_#{key.upcase.gsub('-', '_')}"
end
env[key] = val
end
status, headers, rack_response = app.call(env)
\ No newline at end of file