class Excon::Socket

def request_time_remaining

Raises an exception if we have exceeded the request timeout's deadline.
Returns the remaining time in seconds until we reach the deadline for the request timeout.
def request_time_remaining
  now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  deadline = @data[:deadline]
  raise(Excon::Errors::Timeout.new('request timeout reached')) if now >= deadline
  deadline - now
end