Module: Kibosh::Response::Mixin

Included in:
Kibosh::Response
Defined in:
lib/kibosh/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#streamObject

Returns the value of attribute stream.



6
7
8
# File 'lib/kibosh/response.rb', line 6

def stream
  @stream
end

Instance Method Details

#bodyObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/kibosh/response.rb', line 45

def body
  @body ||=
    begin
      document = Nokogiri::XML::Document.new
      body = document.create_element("body")
      body.attributes.merge! :xmlns => 'http://jabber.org/protocol/httpbind'
      # puts "new body #{body.object_id}"
      document.root = body
    end
end

#body=(body) ⇒ Object



40
41
42
43
# File 'lib/kibosh/response.rb', line 40

def body= body
  raise "hell" if @body
  @body = body
end

#headersObject



36
37
38
# File 'lib/kibosh/response.rb', line 36

def headers
  { "Content-Type" => @session ? @session.content : "text/xml; charset=utf-8" }
end

#rackObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kibosh/response.rb', line 8

def rack
  if deferred
    raise "hell" if defer_fired || deliver_fired
    defer_fired = true
    v = [-1, {}, []].freeze
    puts "[ defer"
  else 
    raise "hell" if deliver_fired
    if @body["type"] == "terminate"
      @callback.receiver.instance_eval do
        @can_persist = false
      end
    end
    deliver_fired = true
    v = [ status || 200, headers, xml ]
    puts "[ #{v[2]}"
  end
  v
end

#statusObject



28
29
30
# File 'lib/kibosh/response.rb', line 28

def status
  @session && @session.ver && 200 || @status
end

#status=(status) ⇒ Object



32
33
34
# File 'lib/kibosh/response.rb', line 32

def status= status
  @status = status
end

#xmlObject



56
57
58
59
60
61
62
# File 'lib/kibosh/response.rb', line 56

def xml
  # puts "sending resp #{self.object_id} body #{@body.object_id}"
  v = @body.document.to_xml :save_with => 0
  # @body["sent"] = "true"
  # puts "sent #{@body}"
  v
end