Skip to content

Commit

Permalink
Merge pull request #483 from mpapis/bugfix/release-3.7.x_fix_check_ex…
Browse files Browse the repository at this point in the history
…ternal_links

Fix single url check for external links, add increasing timeout for slow connection
  • Loading branch information
denisdefreyne committed Nov 3, 2014
2 parents 55651a6 + 07f617f commit e49afdf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/nanoc/extra/checking/checks/external_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,19 @@ def validate(href)

# Get status
res = nil
last_err = nil
timeouts = [3, 5, 10, 30, 60]
5.times do |i|
begin
Timeout.timeout(10) do
Timeout.timeout(timeouts[i]) do
res = request_url_once(url)
if res.code == '405'
res = request_url_once(url, Net::HTTP::Get)
end
end
rescue => e
return Result.new(href, e.message)
last_err = e
next # can not allow
end

if res.code =~ /^3..$/
Expand All @@ -134,7 +137,11 @@ def validate(href)
return Result.new(href, res.code)
end
end
raise 'should not have gotten here'
if last_err
return Result.new(href, last_err.message)
else
raise 'should not have gotten here'
end
end

def path_for_url(url)
Expand Down

0 comments on commit e49afdf

Please sign in to comment.