Method: DigitalFabric::AgentProxy#http_response

Defined in:
lib/tipi/digital_fabric/agent_proxy.rb

#http_response(id, req, body, headers, complete, transfer_count_key) ⇒ Object



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/tipi/digital_fabric/agent_proxy.rb', line 239

def http_response(id, req, body, headers, complete, transfer_count_key)
  if !req.headers_sent? && complete
    req.respond(body, headers|| {})
    if transfer_count_key
      rx, tx = req.transfer_counts
      send_transfer_count(transfer_count_key, rx, tx)
    end
    true
  else
    req.send_headers(headers) if headers && !req.headers_sent?
    req.send_chunk(body, done: complete) if body or complete

    if complete && transfer_count_key
      rx, tx = req.transfer_counts
      send_transfer_count(transfer_count_key, rx, tx)
    end
    complete
  end
rescue IOError, SystemCallError
  # ignore error
end