Class: Ronin::Web::Server::Request

Inherits:
Sinatra::Request
  • Object
show all
Defined in:
lib/ronin/web/server/request.rb

Overview

Convenience class that represents requests.

Instance Method Summary collapse

Instance Method Details

#headersHash{String => String}

The HTTP Headers for the request.

Returns:

  • (Hash{String => String})

    The HTTP Headers of the request.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ronin/web/server/request.rb', line 59

def headers
  headers = {}

  env.each do |name,value|
    if name =~ /^HTTP_/
      header_words = name[5..].split('_')
      header_words.each(&:capitalize!)

      header_name = header_words.join('-')

      headers[header_name] = value
    end
  end

  return headers
end

#ip_with_portString

Returns the remote IP address and port for the request.

Returns:

  • (String)

    The IP address and port number.



43
44
45
46
47
48
49
# File 'lib/ronin/web/server/request.rb', line 43

def ip_with_port
  if env.has_key?('REMOTE_PORT')
    "#{ip}:#{env['REMOTE_PORT']}"
  else
    ip
  end
end