in tools/mirror_check.rb [224:318]
def checkHTTP(base)
# We don't check the pattern on the form for two reasons:
base.strip!
base += '/' unless base.end_with? '/'
base = 'http://' + base unless base.start_with? 'http'
I "Checking #{base} ..."
unless URLMATCH.match(base)
F "Invalid URL syntax: #{base}"
return
end
setup
response = getHTTPHdrs(base)
server = response['server']
if server =~ /Apache/
I "Server: #{server}"
else
W "Server: '#{server}' - expected 'Apache' in server response"
end
time = check_page(base, 'zzz/time.txt', severity = :F)
if time
match = /^(\d+) \S+$/.match(time)
if match
now = Time.now.to_i
stamp = match[1].to_i
age = (now - stamp)/60
if age > 60*24
W "Mirror is over 1 day old: #{age} minutes"
else
I "Mirror is less than 1 day old: #{age} minutes"
end
else
F "Invalid time.txt contents: #{time}"
end
else
return
end
body = check_page(base, '')
checkHdrFtr(base, body)
if %r{<(img|IMG) (src|SRC)="/icons/}.match(body)
I 'Index page has icons as expected'
else
W 'Missing or unexpected img icon tags'
end
checkIndex(body, :tlps)
ibody = check_page(base, 'incubator/')
checkHdrFtr(base+'incubator/', ibody)
checkIndex(ibody, :podlings)
check_page(base, 'harmony/', :E, expectedStatus='404')
zbody = check_page(base, HTTPDIR)
# Not sure this is useful on its own anymore
# It was originally used to detect sites with advertising wrappers,
# but most recent examples have been tables around directory listings
# which is obviously OK as it does not affect the user experience.
# if %r{<table}i.match(zbody)
# W "
checkHdrFtr(base+HTTPDIR, zbody)
if HDRMATCH.match(zbody)
I "Index page for #{HTTPDIR} contains the expected header text"
else
W "Index page for #{HTTPDIR} does not contain the expected header text"
end
if FTRMATCH.match(zbody)
I "Index page for #{HTTPDIR} contains the expected footer text"
else
W "Index page for #{HTTPDIR} does not contain the expected footer text"
end
check_page(base,HTTP404,:E, expectedStatus='404')
MIRRORTEST_FILES.each do |file|
check_CT(base, MIRRORTEST + file)
end
check_redirect(base, 'zzz/mirror-tests/redirect-test/xyz', 'http://www.apache.org/')
end