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

Commit dc55cf8

Browse filesBrowse files
[HttpClient] fixing passing debug info to progress callback
1 parent 5af1e9e commit dc55cf8
Copy full SHA for dc55cf8

File tree

2 files changed

+8
-16
lines changed
Filter options

2 files changed

+8
-16
lines changed

‎src/Symfony/Component/HttpClient/Response/CurlResponse.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/CurlResponse.php
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
5555
$this->info['start_time'] = $this->info['start_time'] ?? microtime(true);
5656
$info = &$this->info;
5757
$headers = &$this->headers;
58+
$debugBuffer = $this->debugBuffer;
5859

5960
if (!$info['response_headers']) {
6061
// Used to keep track of what we're waiting for
@@ -88,9 +89,11 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
8889
if ($onProgress = $options['on_progress']) {
8990
$url = isset($info['url']) ? ['url' => $info['url']] : [];
9091
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
91-
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, static function ($ch, $dlSize, $dlNow) use ($onProgress, &$info, $url, $multi) {
92+
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, static function ($ch, $dlSize, $dlNow) use ($onProgress, &$info, $url, $multi, $debugBuffer) {
9293
try {
93-
$onProgress($dlNow, $dlSize, $url + curl_getinfo($ch) + $info);
94+
rewind($debugBuffer);
95+
$debug = ['debug' => stream_get_contents($debugBuffer)];
96+
$onProgress($dlNow, $dlSize, $url + curl_getinfo($ch) + $info + $debug);
9497
} catch (\Throwable $e) {
9598
$multi->handlesActivity[(int) $ch][] = null;
9699
$multi->handlesActivity[(int) $ch][] = $e;
@@ -148,12 +151,6 @@ public function getInfo(string $type = null)
148151
if (!$info = $this->finalInfo) {
149152
self::perform($this->multi);
150153

151-
if ('debug' === $type) {
152-
rewind($this->debugBuffer);
153-
154-
return stream_get_contents($this->debugBuffer);
155-
}
156-
157154
$info = array_merge($this->info, curl_getinfo($this->handle));
158155
$info['url'] = $this->info['url'] ?? $info['url'];
159156
$info['redirect_url'] = $this->info['redirect_url'] ?? null;
@@ -164,9 +161,10 @@ public function getInfo(string $type = null)
164161
$info['starttransfer_time'] = 0.0;
165162
}
166163

164+
rewind($this->debugBuffer);
165+
$info['debug'] = stream_get_contents($this->debugBuffer);
166+
167167
if (!\in_array(curl_getinfo($this->handle, CURLINFO_PRIVATE), ['headers', 'content'], true)) {
168-
rewind($this->debugBuffer);
169-
$info['debug'] = stream_get_contents($this->debugBuffer);
170168
curl_setopt($this->handle, CURLOPT_VERBOSE, false);
171169
rewind($this->debugBuffer);
172170
ftruncate($this->debugBuffer, 0);

‎src/Symfony/Component/HttpClient/Response/NativeResponse.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/NativeResponse.php
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,12 @@ public function getInfo(string $type = null)
7878
if (!$info = $this->finalInfo) {
7979
self::perform($this->multi);
8080

81-
if ('debug' === $type) {
82-
return $this->info['debug'];
83-
}
84-
8581
$info = $this->info;
8682
$info['url'] = implode('', $info['url']);
8783
unset($info['fopen_time'], $info['size_body'], $info['request_header']);
8884

8985
if (null === $this->buffer) {
9086
$this->finalInfo = $info;
91-
} else {
92-
unset($info['debug']);
9387
}
9488
}
9589

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.