6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/rack-idempotent/default_rescue.rb', line 6
def call(options={})
exception = options[:exception]
status = nil
method = nil
if exception
if IDEMPOTENT_ERROR_CLASSES.include?(exception.class)
return true
elsif exception.class == Rack::Idempotent::HTTPException
status = exception.status
method = exception.request.env["REQUEST_METHOD"]
else
return false
end
end
unless status && method
status = options[:response].status
method = options[:request].env["REQUEST_METHOD"]
end
if method == "GET"
GET_RETRY_HTTP_CODES.include?(status)
elsif method == "POST"
POST_RETRY_HTTP_CODES.include?(status)
else
false
end
end
|