Skip to content

Commit da3104d

Browse files
committed
Add documentation for retry on idempotent methods
1 parent 13ccf40 commit da3104d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

http_client.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,10 @@ Retry Failed Requests
694694
Sometimes, requests fail because of network issues or temporary server errors.
695695
Symfony's HttpClient allows to retry failed requests automatically using the
696696
:ref:`retry_failed option <reference-http-client-retry-failed>`. When enabled,
697-
each failed request with an HTTP status of ``423``, ``425``, ``429``, ``500``,
698-
``502``, ``503``, ``504``, ``507``, or ``510`` is retried up to 3 times, with an
699-
exponential delay between retries (first retry = 1 second; third retry: 4 seconds).
697+
each failed request with an HTTP status of ``423``, ``425``, ``429``, ``502``,
698+
``503`` or with an `idempotent method`_ and a HTTP status of ``500``, ``504``,
699+
``507`` or ``510`` is retried up to 3 times, with an exponential delay between
700+
retries (first retry = 1 second; third retry: 4 seconds).
700701

701702
Check out the full list of configurable :ref:`retry_failed options <reference-http-client-retry-failed>`
702703
to learn how to tweak each of them to fit your application needs.
@@ -1610,3 +1611,4 @@ Then configure Symfony to use your callback:
16101611
.. _`cURL options`: https://www.php.net/manual/en/function.curl-setopt.php
16111612
.. _`Server-sent events`: https://html.spec.whatwg.org/multipage/server-sent-events.html
16121613
.. _`EventSource`: https://www.w3.org/TR/eventsource/#eventsource
1614+
.. _`idempotent method`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods_and_web_applications

reference/configuration/framework.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,10 @@ will automatically retry failed HTTP requests.
782782
retry_failed:
783783
# backoff_service: app.custom_backoff
784784
# decider_service: app.custom_decider
785-
http_codes: [429, 500]
785+
http_codes:
786+
0: ['GET', 'HEAD'] # Retries Network errors when request's method is GET or HEAD
787+
429: true # Alway retries response with 429 status codes
788+
500: ['GET', 'HEAD']
786789
max_retries: 2
787790
delay: 1000
788791
multiplier: 3
@@ -956,13 +959,16 @@ value must use the format ``['header-name' => 'value0, value1, ...']``.
956959
http_codes
957960
..........
958961

959-
**type**: ``array`` **default**: ``[423, 425, 429, 500, 502, 503, 504, 507, 510]``
962+
**type**: ``array`` **default**: empty
960963

961964
.. versionadded:: 5.2
962965

963966
The ``http_codes`` option was introduced in Symfony 5.2.
964967

965968
The list of HTTP status codes that triggers a retry of the request.
969+
When an empty array is provided, the default values from
970+
:method:`Symfony\Component\HttpClient\Retry\GenericRetryStrategy::DEFAULT_RETRY_STATUS_CODES`.
971+
is used.
966972

967973
http_version
968974
............

0 commit comments

Comments
 (0)