You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2017/05/10 10:02:03 UTC
[whimsy] branch master updated: Detect possible redirect loop
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 69ba73c Detect possible redirect loop
new ef09635 Merge branch 'master' of https://gitbox.apache.org/repos/asf/whimsy.git
69ba73c is described below
commit 69ba73c11a82c0f615a972aef4d3f3507322cec0
Author: Sebb <se...@apache.org>
AuthorDate: Wed May 10 11:01:16 2017 +0100
Detect possible redirect loop
---
tools/site-scan.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/site-scan.rb b/tools/site-scan.rb
index eb82d7d..e0bcdb1 100755
--- a/tools/site-scan.rb
+++ b/tools/site-scan.rb
@@ -15,13 +15,17 @@ require 'nokogiri'
require 'json'
# fetch uri, following redirects
-def fetch(uri)
+def fetch(uri, depth=1)
+ if depth > 5
+ raise IOError.new("Too many redirects (#{depth}) detected at #{uri}")
+ end
uri = URI.parse(uri)
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
if response.code =~ /^3\d\d/
- fetch response['location']
+ $stderr.puts "Redirect #{uri}" if $verbose
+ fetch response['location'], depth+1
else
return uri, request, response
end
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].