@@ -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)
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -137,7 +137,8 @@ describe Browser do
|
||||
headers: { 'User-Agent' => 'SomeUA' },
|
||||
ssl_verifypeer: false, ssl_verifyhost: 0,
|
||||
cookiejar: cookie_jar, cookiefile: cookie_jar,
|
||||
timeout: 2000, connecttimeout: 1000
|
||||
timeout: 2000, connecttimeout: 1000,
|
||||
maxredirs: 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +188,14 @@ describe Browser do
|
||||
@expected = default_expectation.merge(params)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the maxredirs is alreday set' do
|
||||
let(:params) { { maxredirs: 100 } }
|
||||
|
||||
it 'does not override it' do
|
||||
@expected = default_expectation.merge(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#forge_request' do
|
||||
|
||||
Reference in New Issue
Block a user