Skip to content

[HttpClient] do not lose response information when truncating the debug buffer #60295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/Response/CurlResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ public function getInfo(?string $type = null): mixed
{
if (!$info = $this->finalInfo) {
$info = array_merge($this->info, curl_getinfo($this->handle));
$info['url'] = $this->info['url'] ?? $info['url'];
$info['redirect_url'] = $this->info['redirect_url'] ?? null;

// workaround curl not subtracting the time offset for pushed responses
Expand All @@ -221,6 +220,7 @@ public function getInfo(?string $type = null): mixed
rewind($this->debugBuffer);
ftruncate($this->debugBuffer, 0);
}
$this->info = array_merge($this->info, $info);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before #60241 getInfo() could have been called multiple times but the debug info would always be present as the debug buffer was never truncated and thus preserved for subsequent calls. This is no longer the case as we truncate the buffer two lines above just after reading it. Following calls of getInfo() would this no longer read the debug information from the buffer but we need to store it at some other place.

$waitFor = curl_getinfo($this->handle, \CURLINFO_PRIVATE);

if ('H' !== $waitFor[0] && 'C' !== $waitFor[0]) {
Expand Down