Repository navigation
fix(client): parse Retry-After per RFC 9110 and never retry a cURL read source - #16
Merged
Merged
Conversation
…ad source Retry-After delay-seconds is now only ASCII digits, so -5 is no longer read as a date offset and 1.5, tomorrow or now fall back to the backoff delay. The IMF-fixdate, RFC 850 and asctime forms are all read as GMT instead of in PHP's default time zone. A request is also sent once while the client's cURL options set CURLOPT_INFILE, CURLOPT_READFUNCTION or CURLOPT_READDATA, because the first attempt consumes that read source and a retry would send an empty body.
DateTimeImmutable::createFromFormat() does not validate the D and l tokens, it shifts the date to the next such weekday, so a wrong day name was read as a date up to six days ahead. The day name is now captured and compared with the parsed date, and the date is rejected on a mismatch. The two-digit year of the RFC 850 form now follows the RFC 9110 50-year rule instead of PHP's fixed 1970 pivot, which made the old rule dead code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RetryAfter: delay-seconds is only^\d+$; negative, fractional and relative values (-5,1.5,tomorrow,now) returnnulland the client falls back to backoff. Previously-5went tostrtotime()and became about 18000 seconds.Client::sendRequest()sends a request once whilecurlOptionssetCURLOPT_INFILE,CURLOPT_READFUNCTIONorCURLOPT_READDATA: the first attempt consumes the read source, so a retry sent an empty body.RetryPolicydocblock,docs/, README and CHANGELOG updated.Test plan
vendor/bin/phpunit(592 tests, 1 pre-existing incomplete)Europe/Istanbul, INFILE/READFUNCTION/READDATA single attempt)vendor/bin/phpstan analysecleanwiki-sync.sh --check repos/HTTP/docspasses