Class: PHPRPC::WEBrickServlet

Inherits:
BaseServer show all
Defined in:
lib/phprpc/webrick_server.rb

Direct Known Subclasses

WEBrickServer

Instance Attribute Summary

Attributes inherited from BaseServer

#charset, #debug

Instance Method Summary collapse

Methods inherited from BaseServer

#add, #call, #call!, #initialize

Constructor Details

This class inherits a constructor from PHPRPC::BaseServer

Instance Method Details

#get_instance(*a) ⇒ Object



38
39
40
# File 'lib/phprpc/webrick_server.rb', line 38

def get_instance(*a)
  self
end

#service(request, response) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/phprpc/webrick_server.rb', line 42

def service(request, response)
  env = request.meta_vars
  env.delete_if { |k, v| v.nil? }
  env["HTTPS"] = ENV["HTTPS"]
  env["rack.input"] = StringIO.new(request.body.to_s)
  env['rack.multithread'] = true # this variable only used for rack pool session on debug mode
  env["rack.url_scheme"] = ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
  env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
  env["QUERY_STRING"] ||= ""
  env["REQUEST_PATH"] ||= "/"
  status, headers, body = @app.call(env)
  response.status = status.to_i
  headers.each { |k, v| response[k] = v }
  response.body = body
end