class Object
Constants
- HTTP1Adapter
- HTTP2Adapter
- ResourcePool
- Response
- SiteConnectionManager
Public Instance Methods
env(request)
click to toggle source
# File lib/polyphony/http/server/rack.rb, line 34 def env(request) { 'REQUEST_METHOD' => request.method, 'SCRIPT_NAME' => '', 'PATH_INFO' => request.path, 'QUERY_STRING' => request.query_string || '', 'SERVER_NAME' => request.headers['Host'], # ? 'SERVER_PORT' => '80', # ? 'rack.version' => Rack::VERSION, 'rack.url_scheme' => 'https', # ? 'rack.input' => InputStream.new(request), 'rack.errors' => STDERR, # ? 'rack.multithread' => false, 'rack.run_once' => false, 'rack.hijack?' => false, 'rack.hijack' => nil, 'rack.hijack_io' => nil, 'rack.session' => nil, 'rack.logger' => nil, 'rack.multipart.buffer_size' => nil, 'rack.multipar.tempfile_factory' => nil }.tap do |env| request.headers.each { |k, v| env["HTTP_#{k.upcase}"] = v } end end
handler(&block)
click to toggle source
# File lib/polyphony/websocket.rb, line 55 def handler(&block) proc { |client, header| block.(WebsocketConnection.new(client, header)) } end
load(path)
click to toggle source
# File lib/polyphony/http/server/rack.rb, line 11 def load(path) src = IO.read(path) instance_eval(src, path, 1) end
respond(request, (status_code, headers, body))
click to toggle source
# File lib/polyphony/http/server/rack.rb, line 60 def respond(request, (status_code, headers, body)) headers[':status'] = status_code.to_s puts "headers: #{headers.inspect}" request.respond(body.first, headers) end
run(app)
click to toggle source
# File lib/polyphony/http/server/rack.rb, line 7 def run(app) ->(req) { respond(req, app.(env(req))) } end