Class: Zero::Request::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/zero/request/server.rb

Overview

This class represents all server related information of a request.

Constant Summary collapse

KEY_SERVER_NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

the key for the server name

'SERVER_NAME'
KEY_SERVER_PORT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

the key for the server port

'SERVER_PORT'
KEY_SERVER_PROTOCOL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

the key for the server protocol

'SERVER_PROTOCOL'
KEY_SERVER_SOFTWARE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

the key for the server software

'SERVER_SOFTWARE'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Server

This creates a new server instance extracting all server related

information from the environment.


20
21
22
23
24
25
# File 'lib/zero/request/server.rb', line 20

def initialize(environment)
  @hostname = environment[KEY_SERVER_NAME]
  @port     = environment[KEY_SERVER_PORT].to_i
  @protocol = environment[KEY_SERVER_PROTOCOL]
  @software = environment[KEY_SERVER_SOFTWARE]
end

Instance Attribute Details

#hostnameString (readonly)

get the hostname of the server

Returns:

  • (String)

    the hostname



32
33
34
# File 'lib/zero/request/server.rb', line 32

def hostname
  @hostname
end

#portNumeric (readonly)

get the port

Returns:

  • (Numeric)

    the port



29
30
31
# File 'lib/zero/request/server.rb', line 29

def port
  @port
end

#protocolString (readonly)

get the protocol of the server (normally it should be HTTP/1.1)

Returns:

  • (String)

    the protocol



35
36
37
# File 'lib/zero/request/server.rb', line 35

def protocol
  @protocol
end

#softwareString (readonly)

get the server software

Returns:

  • (String)

    the server software name



38
39
40
# File 'lib/zero/request/server.rb', line 38

def software
  @software
end