Class: Vines::Stream::Http

Inherits:
Client
  • Object
show all
Defined in:
lib/vines/backdoor/stream/http.rb,
lib/vines/backdoor/stream/http/start.rb

Defined Under Namespace

Classes: Start

Constant Summary collapse

MECHANISMS =
%w[PLAIN INTERNAL].freeze

Instance Method Summary collapse

Instance Method Details

#authentication_mechanismsObject



11
12
13
# File 'lib/vines/backdoor/stream/http.rb', line 11

def authentication_mechanisms
  MECHANISMS
end

#backdoor(*args) ⇒ Object



7
8
9
# File 'lib/vines/backdoor/stream/http.rb', line 7

def backdoor(*args)
  config[:http].backdoor(*args)
end

#start_session(node) ⇒ Object

Raises:

  • (StreamErrors::UndefinedCondition)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vines/backdoor/stream/http.rb', line 15

def start_session(node)
  domain, type, hold, wait, rid = %w[to content hold wait rid].map {|a| (node[a] || '').strip }
  version = node.attribute_with_ns('version', NAMESPACES[:bosh]).value rescue nil

  @session.inactivity = 20
  @session.domain = domain
  @session.content_type = type unless type.empty?
  @session.hold = hold.to_i unless hold.empty?
  @session.wait = wait.to_i unless wait.empty?

  raise StreamErrors::UndefinedCondition.new('rid required') if rid.empty?
  raise StreamErrors::UnsupportedVersion unless version == '1.0'
  raise StreamErrors::ImproperAddressing unless valid_address?(domain)
  raise StreamErrors::HostUnknown unless config.vhost?(domain)
  raise StreamErrors::InvalidNamespace unless node.namespaces['xmlns'] == NAMESPACES[:http_bind]

  Sessions[@session.id] = @session
end