Module: Osprey

Defined in:
lib/osprey.rb,
lib/osprey/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

MAX_CONCURRENT_FIBERS =
1000
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.callObject



15
16
17
# File 'lib/osprey.rb', line 15

def self.call(...)
  @handler.call(to_env(...))
end

.to_env(query_string, remote_addr, path_info, script_name, method, host, scheme, version, protocol, port, fd, headers, hijack_proc) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/osprey.rb', line 19

def self.to_env(
  (query_string, remote_addr, path_info), script_name, method, host, scheme, version,
  protocol, port, fd, headers, hijack_proc
)
env = {
  "SERVER_SOFTWARE" => "Osprey",
  "SCRIPT_NAME" => script_name,
  "REQUEST_METHOD" => method,
  "PATH_INFO" => path_info,
  "QUERY_STRING" => query_string,
  "REMOTE_ADDR" => remote_addr,
  "SERVER_NAME" => host,
  "SERVER_PORT" => port,
  "SERVER_PROTOCOL" => protocol,
  "HTTP_HOST" => host,
  "HTTP_VERSION" => version,
  "rack.url_scheme" => scheme,
  "rack.hijack_enabled?" => true,
  "rack.hijack" => hijack_proc,
  "rack.protocol" => protocol,
  "rack.input" => fd.positive? ? IO.new(fd, "rb") : StringIO.new,
  "rack.errors" => $stderr,
  "rack.multipart.buffer_size" => 16_384,
  }.merge(
    headers.transform_keys do |k|
      case k
      when "content-length" then "CONTENT_LENGTH"
      when "content-type" then "CONTENT_TYPE"
      when "authorization" then "AUTH_TYPE"
      else "HTTP_#{k.upcase.tr("-", "_")}"
      end
    end
  )
end