Class: Net::PTTH::IncomingRequest

Inherits:
Struct
  • Object
show all
Defined in:
lib/net/ptth/incoming_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



2
3
4
# File 'lib/net/ptth/incoming_request.rb', line 2

def body
  @body
end

#headersObject

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



2
3
4
# File 'lib/net/ptth/incoming_request.rb', line 2

def headers
  @headers
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



2
3
4
# File 'lib/net/ptth/incoming_request.rb', line 2

def method
  @method
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



2
3
4
# File 'lib/net/ptth/incoming_request.rb', line 2

def path
  @path
end

Instance Method Details

#to_envObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/net/ptth/incoming_request.rb', line 3

def to_env
  env = {
    "PATH_INFO" => path,
    "SCRIPT_NAME" => "",
    "rack.input" => StringIO.new(body || ""),
    "REQUEST_METHOD" => method,
  }

  env.tap { |h| h["CONTENT_LENGTH"] = body.length if !body.nil? }

  env.merge!(headers) if headers
end