def http_send_once(kind, target, packet, received_at, &callback)
      begin
        method = packet.class.name.split("::").last.downcase
        options = {:request_uuid => packet.token}
        options[:time_to_live] = (packet.expires_at - Time.now.to_i) if packet.expires_at > 0
        result = success_result(@agent.client.send(method, packet.type, packet.payload, target, options))
      rescue Exceptions::Unauthorized => e
        result = error_result(e.message)
      rescue Exceptions::ConnectivityFailure => e
        if queueing?
          @offline_handler.queue_request(kind, packet.type, packet.payload, target, packet.token, packet.expires_at, packet.skewed_by, &callback)
          result = nil
        else
          result = retry_result(e.message)
        end
      rescue Exceptions::RetryableError => e
        result = retry_result(e.message)
      rescue Exceptions::InternalServerError => e
        result = error_result("#{e.server} internal error")
      rescue Exceptions::Terminating => e
        result = nil
      rescue StandardError => e
        # These errors are either unexpected errors or HttpExceptions with an http_body
        # giving details about the error that are conveyed in the error_result
        if e.respond_to?(:http_body)
          # No need to log here since any HTTP request errors have already been logged
          result = error_result(e.inspect)
        else
          agent_type = AgentIdentity.parse(@identity).agent_type
          ErrorTracker.log(self, "Failed to send #{packet.trace} #{packet.type}", e)
          result = error_result("#{agent_type.capitalize} agent internal error")
        end
      end

      if result && packet.is_a?(Request)
        result = Result.new(packet.token, @identity, result, from = packet.target)
        result.received_at = received_at.to_f
        @pending_requests[packet.token] = PendingRequest.new(kind, received_at, callback) if callback
        handle_response(result)
      end
      true
    end
def http_send_once(kind, target, packet, received_at, &callback)
      begin
        method = packet.class.name.split("::").last.downcase
        options = {:request_uuid => packet.token}
        options[:time_to_live] = (packet.expires_at - Time.now.to_i) if packet.expires_at > 0
        result = success_result(@agent.client.send(method, packet.type, packet.payload, target, options))
      rescue Exceptions::Unauthorized => e
        result = error_result(e.message)
      rescue Exceptions::ConnectivityFailure => e
        if queueing?
          @offline_handler.queue_request(kind, packet.type, packet.payload, target, packet.token, packet.expires_at, packet.skewed_by, &callback)
          result = nil
        else
          result = retry_result(e.message)
        end
      rescue Exceptions::RetryableError => e
        result = retry_result(e.message)
      rescue Exceptions::InternalServerError => e
        result = error_result("#{e.server} internal error")
      rescue Exceptions::Terminating => e
        result = nil
      rescue StandardError => e
        # These errors are either unexpected errors or HttpExceptions with an http_body
        # giving details about the error that are conveyed in the error_result
        if e.respond_to?(:http_body)
          # No need to log here since any HTTP request errors have already been logged
          result = error_result(e.inspect)
        else
          agent_type = AgentIdentity.parse(@identity).agent_type
          ErrorTracker.log(self, "Failed to send #{packet.trace} #{packet.type}", e)
          result = error_result("#{agent_type.capitalize} agent internal error")
        end
      end

      if result && packet.is_a?(Request)
        result = Result.new(packet.token, @identity, result, from = packet.target)
        result.received_at = received_at.to_f
        @pending_requests[packet.token] = PendingRequest.new(kind, received_at, callback) if callback
        handle_response(result)
      end
      true
    end
Send request via HTTP and then immediately handle response

 === Parameters
 kind(Symbol):: Kind of request: :send_push or :send_request
 target(Hash|NilClass):: Target for request
 packet(Push|Request):: Request packet to send
 received_at(Time):: Time when request received

 === Block
 Optional block used to process response asynchronously with the following parameter:
   result(Result):: Response with an OperationResult of SUCCESS, RETRY, NON_DELIVERY, or ERROR

 === Return
 true:: Always return true