Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix a few small issues:

- retry_after may equal the limit
- someone (net/http?) lowercases header names?!
- better short circuit for integer Retry-After
  • Loading branch information...
commit 3787e8a1f014f1c71b55c77a0af15096911c1ef0 1 parent 6b39612
Nick Zadrozny authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/rsolr/client.rb
8 lib/rsolr/client.rb
View
@@ -183,15 +183,17 @@ def retry_503?(request_context, response)
return false unless retry_503 && retry_503 > 0
retry_after_limit = request_context[:retry_after_limit] || 1
retry_after = retry_after(response)
- return false unless retry_after && retry_after < retry_after_limit
+ return false unless retry_after && retry_after <= retry_after_limit
true
end
# Retry-After can be a relative number of seconds from now, or an RFC 1123 Date.
# If the latter, attempt to convert it to a relative time in seconds.
def retry_after(response)
- retry_after = response[:headers]['Retry-After']
- if retry_after.is_a?(String)
+ retry_after = Array(response[:headers]['Retry-After'] || response[:headers]['retry-after']).flatten.first
+ if retry_after =~ /\A[0-9]+\Z/
+ retry_after = retry_after.to_i
+ else
begin
retry_after_date = DateTime.parse(retry_after)
retry_after = retry_after_date.to_time - Time.now
Please sign in to comment.
Something went wrong with that request. Please try again.