@@ -55,6 +55,7 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
55
55
$ this ->info ['start_time ' ] = $ this ->info ['start_time ' ] ?? microtime (true );
56
56
$ info = &$ this ->info ;
57
57
$ headers = &$ this ->headers ;
58
+ $ debugBuffer = $ this ->debugBuffer ;
58
59
59
60
if (!$ info ['response_headers ' ]) {
60
61
// Used to keep track of what we're waiting for
@@ -88,9 +89,11 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
88
89
if ($ onProgress = $ options ['on_progress ' ]) {
89
90
$ url = isset ($ info ['url ' ]) ? ['url ' => $ info ['url ' ]] : [];
90
91
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 ) {
92
93
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 );
94
97
} catch (\Throwable $ e ) {
95
98
$ multi ->handlesActivity [(int ) $ ch ][] = null ;
96
99
$ multi ->handlesActivity [(int ) $ ch ][] = $ e ;
@@ -148,12 +151,6 @@ public function getInfo(string $type = null)
148
151
if (!$ info = $ this ->finalInfo ) {
149
152
self ::perform ($ this ->multi );
150
153
151
- if ('debug ' === $ type ) {
152
- rewind ($ this ->debugBuffer );
153
-
154
- return stream_get_contents ($ this ->debugBuffer );
155
- }
156
-
157
154
$ info = array_merge ($ this ->info , curl_getinfo ($ this ->handle ));
158
155
$ info ['url ' ] = $ this ->info ['url ' ] ?? $ info ['url ' ];
159
156
$ info ['redirect_url ' ] = $ this ->info ['redirect_url ' ] ?? null ;
@@ -164,9 +161,10 @@ public function getInfo(string $type = null)
164
161
$ info ['starttransfer_time ' ] = 0.0 ;
165
162
}
166
163
164
+ rewind ($ this ->debugBuffer );
165
+ $ info ['debug ' ] = stream_get_contents ($ this ->debugBuffer );
166
+
167
167
if (!\in_array (curl_getinfo ($ this ->handle , CURLINFO_PRIVATE ), ['headers ' , 'content ' ], true )) {
168
- rewind ($ this ->debugBuffer );
169
- $ info ['debug ' ] = stream_get_contents ($ this ->debugBuffer );
170
168
curl_setopt ($ this ->handle , CURLOPT_VERBOSE , false );
171
169
rewind ($ this ->debugBuffer );
172
170
ftruncate ($ this ->debugBuffer , 0 );
0 commit comments