Skip to content

Commit

Permalink
[HttpClient] filter verbose debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Mar 12, 2020
1 parent d0b7445 commit eb91028
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Symfony/Component/HttpClient/Response/CurlResponse.php
Expand Up @@ -138,8 +138,24 @@ public function getInfo(string $type = null)
$info['starttransfer_time'] = 0.0;
}

$info['debug'] = '';
$rewriteDebug = false;
rewind($this->debugBuffer);
$info['debug'] = stream_get_contents($this->debugBuffer);
while (false !== $b = fgets($this->debugBuffer)) {
// skip repetitive messages
if (preg_match('/^\* Expire in \d+ ms for /', $b)) {
$rewriteDebug = true;
} else {
$info['debug'] .= $b;
}
}

if ($rewriteDebug) {
ftruncate($this->debugBuffer, \strlen($info['debug']));
rewind($this->debugBuffer);
fwrite($this->debugBuffer, $info['debug']);
}

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

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

0 comments on commit eb91028

Please sign in to comment.