Conversation
`CURLINFO_REDIRECT_COUNT` is only non-zero when `CURLOPT_FOLLOWLOCATION` is enabled but we track redirects ourselves since 692e8bc. https://curl.se/libcurl/c/CURLOPT_FOLLOWLOCATION.html https://curl.se/libcurl/c/CURLINFO_REDIRECT_COUNT.html
Since starting to handle redirects ourselves in 692e8bc, `url` info item (aka `CURLINFO_EFFECTIVE_URL`) will be the same as the initial URI.
In fact, when the server sends interim responses, this was counterproductive – it would overwrite the final response code returned by `CURLINFO_HTTP_CODE` with the interim one (e.g. 100). Though, the parser will still include the headers of all but the first response in the body.
Explicit comparison is clearer than relying on `CURLE_OK` being falsey (`0`).
This is only needed for PHPStan. Making the type assertion explicit and moving it earlier will allow us to make the `prepareHeaders` call conditional without having to add more casts.
e8e6e42 to
f28edc4
Compare
The method call was introduced in 4b1fc33 to support tunneling through HTTP proxy using CONNECT method, whose response curl includes in the `curl_exec` result. Ideally, we would prevent that with `CURLOPT_SUPPRESS_CONNECT_HEADERS` but that is only available in PHP 7.3: https://www.php.net/manual/en/curl.constants.php#constant.curlopt-suppress-connect-headers
Alkarex
approved these changes
Sep 27, 2025
Art4
approved these changes
Sep 29, 2025
This was referenced Sep 30, 2025
Closed
Alkarex
added a commit
to FreshRSS/simplepie
that referenced
this pull request
Sep 30, 2025
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.
Remove redundant redirect count check:
CURLINFO_REDIRECT_COUNTis only non-zero whenCURLOPT_FOLLOWLOCATIONis enabled but we track redirects ourselves since 692e8bc.Remove redundant url setting: Since starting to handle redirects ourselves in 692e8bc,
urlinfo item (akaCURLINFO_EFFECTIVE_URL) will be the same as the initial URI.Remove redundant status_code setting: In fact, when the server sends interim responses, this was counterproductive – it would overwrite the final response code returned by
CURLINFO_HTTP_CODEwith the interim one (e.g. 100). Though, the parser will still include the headers of all but the first response in the body.Avoid truthiness conversion of
curl_errno: Explicit comparison is clearer than relying onCURLE_OKbeing falsey (0).Replace redundant string cast with assertion: This is only needed for PHPStan. Making the type assertion explicit and moving it earlier will allow us to make the
prepareHeaderscall conditional without having to add more casts.Make “header preparation” conditional: The method call was introduced in 4b1fc33 to support tunneling through HTTP proxy using CONNECT method, whose response curl includes in the
curl_execresult. Ideally, we would prevent that withCURLOPT_SUPPRESS_CONNECT_HEADERSbut that is only available in PHP 7.3.