mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-09-01 00:00:35 -04:00
allow only idempotent requests to be retried
This commit is contained in:
parent
694549eb95
commit
3d305285d5
@ -4,6 +4,7 @@ module HTTPX
|
||||
module Plugins
|
||||
module Retries
|
||||
MAX_RETRIES = 3
|
||||
IDEMPOTENT_METHODS = [:get, :options, :head, :put, :delete]
|
||||
|
||||
module InstanceMethods
|
||||
def max_retries(n)
|
||||
@ -15,7 +16,8 @@ module HTTPX
|
||||
def fetch_response(request)
|
||||
response = super
|
||||
if response.is_a?(ErrorResponse) &&
|
||||
request.retries > 0
|
||||
request.retries > 0 &&
|
||||
IDEMPOTENT_METHODS.include?(request.verb)
|
||||
request.retries -= 1
|
||||
channel = find_channel(request)
|
||||
channel.send(request)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user