@@ -181,8 +181,6 @@ module Agents |
||
181 | 181 |
else |
182 | 182 |
if consider_success.map(&:class).uniq != [Fixnum] |
183 | 183 |
errors.add(:base,"Please make sure to use only integer values for code") |
184 |
- else |
|
185 |
- @error_codes_considered_success = consider_success |
|
186 | 184 |
end |
187 | 185 |
end |
188 | 186 |
end |
@@ -297,6 +295,7 @@ module Agents |
||
297 | 295 |
uri = Utils.normalize_uri(url) |
298 | 296 |
log "Fetching #{uri}" |
299 | 297 |
response = faraday.get(uri) |
298 |
+ |
|
300 | 299 |
raise "Failed: #{response.inspect}" unless consider_response_successful?(response) |
301 | 300 |
|
302 | 301 |
interpolation_context.stack { |
@@ -379,7 +378,8 @@ module Agents |
||
379 | 378 |
private |
380 | 379 |
def consider_response_successful?(response) |
381 | 380 |
response.success? || begin |
382 |
- @error_codes_considered_success.present? && @error_codes_considered_success.include?(response.status) |
|
381 |
+ consider_success = options["consider_http_error_success"] |
|
382 |
+ consider_success.present? && consider_success.include?(response.status) |
|
383 | 383 |
end |
384 | 384 |
end |
385 | 385 |
|
@@ -202,7 +202,7 @@ describe Agents::WebsiteAgent do |
||
202 | 202 |
'type' => "json", |
203 | 203 |
'url' => "http://gzip.com", |
204 | 204 |
'mode' => 'on_change', |
205 |
- 'consider_http_error_success': [404], |
|
205 |
+ 'consider_http_error_success' => [404], |
|
206 | 206 |
'extract' => { |
207 | 207 |
'version' => { 'path' => 'response.version' }, |
208 | 208 |
}, |