Class: OverSIP::WebSocket::HttpRequest

Inherits:
Hash
  • Object
show all
Includes:
Logger
Defined in:
lib/oversip/websocket/http_request.rb

Constant Summary collapse

LOG_ID =
"HTTP WS Request"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

fg_system_msg2str, load_methods

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



7
8
9
# File 'lib/oversip/websocket/http_request.rb', line 7

def connection
  @connection
end

#content_lengthObject (readonly)

Returns the value of attribute content_length.



19
20
21
# File 'lib/oversip/websocket/http_request.rb', line 19

def content_length
  @content_length
end

#hdr_connectionObject (readonly)

Returns the value of attribute hdr_connection.



20
21
22
# File 'lib/oversip/websocket/http_request.rb', line 20

def hdr_connection
  @hdr_connection
end

#hdr_originObject (readonly)

Returns the value of attribute hdr_origin.



22
23
24
# File 'lib/oversip/websocket/http_request.rb', line 22

def hdr_origin
  @hdr_origin
end

#hdr_sec_websocket_keyObject (readonly)

Returns the value of attribute hdr_sec_websocket_key.



24
25
26
# File 'lib/oversip/websocket/http_request.rb', line 24

def hdr_sec_websocket_key
  @hdr_sec_websocket_key
end

#hdr_sec_websocket_protocolObject (readonly)

Returns the value of attribute hdr_sec_websocket_protocol.



25
26
27
# File 'lib/oversip/websocket/http_request.rb', line 25

def hdr_sec_websocket_protocol
  @hdr_sec_websocket_protocol
end

#hdr_sec_websocket_versionObject (readonly)

Returns the value of attribute hdr_sec_websocket_version.



23
24
25
# File 'lib/oversip/websocket/http_request.rb', line 23

def hdr_sec_websocket_version
  @hdr_sec_websocket_version
end

#hdr_upgradeObject (readonly)

Returns the value of attribute hdr_upgrade.



21
22
23
# File 'lib/oversip/websocket/http_request.rb', line 21

def hdr_upgrade
  @hdr_upgrade
end

#hostObject (readonly)

Returns the value of attribute host.



17
18
19
# File 'lib/oversip/websocket/http_request.rb', line 17

def host
  @host
end

#http_methodObject (readonly)

HTTP request attributes.



10
11
12
# File 'lib/oversip/websocket/http_request.rb', line 10

def http_method
  @http_method
end

#http_versionObject (readonly)

Returns the value of attribute http_version.



11
12
13
# File 'lib/oversip/websocket/http_request.rb', line 11

def http_version
  @http_version
end

#portObject (readonly)

Returns the value of attribute port.



18
19
20
# File 'lib/oversip/websocket/http_request.rb', line 18

def port
  @port
end

#uriObject (readonly)

Returns the value of attribute uri.



13
14
15
# File 'lib/oversip/websocket/http_request.rb', line 13

def uri
  @uri
end

#uri_fragmentObject (readonly)

Returns the value of attribute uri_fragment.



16
17
18
# File 'lib/oversip/websocket/http_request.rb', line 16

def uri_fragment
  @uri_fragment
end

#uri_pathObject (readonly)

Returns the value of attribute uri_path.



14
15
16
# File 'lib/oversip/websocket/http_request.rb', line 14

def uri_path
  @uri_path
end

#uri_queryObject (readonly)

Returns the value of attribute uri_query.



15
16
17
# File 'lib/oversip/websocket/http_request.rb', line 15

def uri_query
  @uri_query
end

#uri_schemeObject (readonly)

Returns the value of attribute uri_scheme.



12
13
14
# File 'lib/oversip/websocket/http_request.rb', line 12

def uri_scheme
  @uri_scheme
end

Instance Method Details

#log_idObject



29
30
31
# File 'lib/oversip/websocket/http_request.rb', line 29

def log_id
  LOG_ID
end

#reply(status_code, reason_phrase = nil, extra_headers = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/oversip/websocket/http_request.rb', line 36

def reply status_code, reason_phrase=nil, extra_headers={}
  reason_phrase ||= REASON_PHRASE[status_code] || REASON_PHRASE_NOT_SET
  extra_headers ||= {}

  response = "#{@http_version} #{status_code} #{reason_phrase}\r\n"

  extra_headers.each {|header| response << header << "\r\n"}

  response << HDR_SERVER << "\r\n\r\n"

  log_system_debug "replying #{status_code} \"#{reason_phrase}\""  if $oversip_debug

  if @connection.error?
    log_system_warn "cannot send response, connection is closed"
    return false
  end

  @connection.send_data response
  return true
end

#unknown_method?Boolean

Returns:

  • (Boolean)


33
# File 'lib/oversip/websocket/http_request.rb', line 33

def unknown_method?  ;  @is_unknown_method  end