Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpClient] fixing passing debug info to progress callback #32083

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
Jun 23, 2019
Merged
Show file tree
Hide file tree
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
18 changes: 8 additions & 10 deletions 18 src/Symfony/Component/HttpClient/Response/CurlResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
$this->info['start_time'] = $this->info['start_time'] ?? microtime(true);
$info = &$this->info;
$headers = &$this->headers;
$debugBuffer = $this->debugBuffer;

if (!$info['response_headers']) {
// Used to keep track of what we're waiting for
Expand Down Expand Up @@ -88,9 +89,11 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
if ($onProgress = $options['on_progress']) {
$url = isset($info['url']) ? ['url' => $info['url']] : [];
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, static function ($ch, $dlSize, $dlNow) use ($onProgress, &$info, $url, $multi) {
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, static function ($ch, $dlSize, $dlNow) use ($onProgress, &$info, $url, $multi, $debugBuffer) {
try {
$onProgress($dlNow, $dlSize, $url + curl_getinfo($ch) + $info);
rewind($debugBuffer);
$debug = ['debug' => stream_get_contents($debugBuffer)];
$onProgress($dlNow, $dlSize, $url + curl_getinfo($ch) + $info + $debug);
} catch (\Throwable $e) {
$multi->handlesActivity[(int) $ch][] = null;
$multi->handlesActivity[(int) $ch][] = $e;
Expand Down Expand Up @@ -148,12 +151,6 @@ public function getInfo(string $type = null)
if (!$info = $this->finalInfo) {
self::perform($this->multi);

if ('debug' === $type) {
rewind($this->debugBuffer);

return stream_get_contents($this->debugBuffer);
}

$info = array_merge($this->info, curl_getinfo($this->handle));
$info['url'] = $this->info['url'] ?? $info['url'];
$info['redirect_url'] = $this->info['redirect_url'] ?? null;
Expand All @@ -164,9 +161,10 @@ public function getInfo(string $type = null)
$info['starttransfer_time'] = 0.0;
}

rewind($this->debugBuffer);
$info['debug'] = stream_get_contents($this->debugBuffer);

if (!\in_array(curl_getinfo($this->handle, CURLINFO_PRIVATE), ['headers', 'content'], true)) {
rewind($this->debugBuffer);
$info['debug'] = stream_get_contents($this->debugBuffer);
curl_setopt($this->handle, CURLOPT_VERBOSE, false);
rewind($this->debugBuffer);
ftruncate($this->debugBuffer, 0);
Expand Down
6 changes: 0 additions & 6 deletions 6 src/Symfony/Component/HttpClient/Response/NativeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,12 @@ public function getInfo(string $type = null)
if (!$info = $this->finalInfo) {
self::perform($this->multi);

if ('debug' === $type) {
return $this->info['debug'];
}

$info = $this->info;
$info['url'] = implode('', $info['url']);
unset($info['fopen_time'], $info['size_body'], $info['request_header']);

if (null === $this->buffer) {
$this->finalInfo = $info;
} else {
unset($info['debug']);
}
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.