Fix #228, #327 Infinite loop when self-redirect

This commit is contained in:
erwanlr
2013-11-18 11:20:15 +00:00
parent 0c2937936b
commit 1c34f48c39
3 changed files with 20 additions and 12 deletions

View File

@@ -120,18 +120,14 @@ class Browser
)
end
if @request_timeout
params = params.merge(timeout: @request_timeout)
end
if @connect_timeout
params = params.merge(connecttimeout: @connect_timeout)
end
params.merge!(timeout: @request_timeout) if @request_timeout
params.merge!(connecttimeout: @connect_timeout) if @connect_timeout
# Used to enable the cache system if :cache_ttl > 0
unless params.has_key?(:cache_ttl)
params = params.merge(cache_ttl: @cache_ttl)
end
params.merge!(cache_ttl: @cache_ttl) unless params.has_key?(:cache_ttl)
# Prevent infinite self redirection
params.merge!(maxredirs: 3) unless params.has_key?(:maxredirs)
# Disable SSL-Certificate checks
params.merge!(ssl_verifypeer: false)

View File

@@ -29,7 +29,10 @@ class WpItem
#
# @return [ Boolean ]
def exists_from_response?(response, options = {})
if [200, 401, 403].include?(response.code)
# 301 included as some items do a self-redirect
# Redirects to the 404 and homepage should be ignored (unless dynamic content is used)
# by the page hashes (error_404_hash & homepage_hash)
if [200, 401, 403, 301].include?(response.code)
if response.has_valid_hash?(options[:error_404_hash], options[:homepage_hash])
if options[:exclude_content]
unless response.body.match(options[:exclude_content])