Exception: Restify::TooManyRequests

Inherits:
ClientError show all
Defined in:
lib/restify/error.rb

Instance Attribute Summary

Attributes inherited from ResponseError

#response

Instance Method Summary collapse

Methods inherited from ResponseError

#code, #errors, from_code, #initialize, #status

Constructor Details

This class inherits a constructor from Restify::ResponseError

Instance Method Details

#retry_afterObject



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/restify/error.rb', line 127

def retry_after
  case response.headers['RETRY_AFTER']
    when /^\d+$/
      DateTime.now + Rational(response.headers['RETRY_AFTER'].to_i, 86_400)
    when String
      begin
        DateTime.httpdate response.headers['RETRY_AFTER']
      rescue ArgumentError
        nil
      end
  end
end