Handle Posterous rate limiting

This commit is contained in:
Beau Simensen 2012-01-22 20:58:56 -08:00
parent 5d6e87bbf3
commit 0284b8b22f
1 changed files with 5 additions and 0 deletions

View File

@ -29,6 +29,11 @@ module Jekyll
case response case response
when Net::HTTPSuccess then response when Net::HTTPSuccess then response
when Net::HTTPRedirection then fetch(response['location'], limit - 1) when Net::HTTPRedirection then fetch(response['location'], limit - 1)
when Net::HTTPForbidden then
retry_after = response.to_hash['retry-after'][0]
puts "We have been told to try again after #{retry_after} seconds"
sleep(retry_after.to_i + 1)
fetch(uri_str, limit - 1)
else response.error! else response.error!
end end
end end