lib/vines/stream/http/session.rb in vines-0.1.1 vs lib/vines/stream/http/session.rb in vines-0.2.0
- old
+ new
@@ -55,35 +55,37 @@
@state.node(node)
end
def request(request)
if @responses.any?
- request.reply(wrap_body(@responses.join))
+ request.reply(wrap_body(@responses.join), @content_type)
@replied = Time.now
@responses.clear
else
while @requests.size >= @hold
- @requests.shift.reply(wrap_body(''))
+ @requests.shift.reply(wrap_body(''), @content_type)
@replied = Time.now
end
@requests << request
end
end
# Send an HTTP 200 OK response wrapping the XMPP node content back
# to the client.
def reply(node)
- @requests.shift.reply(node)
- @replied = Time.now
+ if request = @requests.shift
+ request.reply(node, @content_type)
+ @replied = Time.now
+ end
end
# Write the XMPP node to the client stream after wrapping it in a BOSH
# body tag. If there's a waiting request, the node is written
# immediately. If not, it's queued until the next request arrives.
def write(node)
if request = @requests.shift
- request.reply(wrap_body(node))
+ request.reply(wrap_body(node), @content_type)
@replied = Time.now
else
@responses << node.to_s
end
end
@@ -95,10 +97,10 @@
private
def respond_to_expired_requests
expired = @requests.select {|req| req.age > @wait }
expired.each do |request|
- request.reply(wrap_body(''))
+ request.reply(wrap_body(''), @content_type)
@requests.delete(request)
@replied = Time.now
end
end