@@ -126,9 +126,14 @@ public function __construct(
126
126
curl_setopt ($ ch , \CURLOPT_NOPROGRESS , false );
127
127
curl_setopt ($ ch , \CURLOPT_PROGRESSFUNCTION , static function ($ ch , $ dlSize , $ dlNow ) use ($ onProgress , &$ info , $ url , $ multi , $ debugBuffer ) {
128
128
try {
129
+ $ info ['debug ' ] ??= '' ;
129
130
rewind ($ debugBuffer );
130
- $ debug = ['debug ' => stream_get_contents ($ debugBuffer )];
131
- $ onProgress ($ dlNow , $ dlSize , $ url + curl_getinfo ($ ch ) + $ info + $ debug );
131
+ if (fstat ($ debugBuffer )['size ' ]) {
132
+ $ info ['debug ' ] .= stream_get_contents ($ debugBuffer );
133
+ rewind ($ debugBuffer );
134
+ ftruncate ($ debugBuffer , 0 );
135
+ }
136
+ $ onProgress ($ dlNow , $ dlSize , $ url + curl_getinfo ($ ch ) + $ info );
132
137
} catch (\Throwable $ e ) {
133
138
$ multi ->handlesActivity [(int ) $ ch ][] = null ;
134
139
$ multi ->handlesActivity [(int ) $ ch ][] = $ e ;
@@ -209,14 +214,17 @@ public function getInfo(?string $type = null): mixed
209
214
$ info ['starttransfer_time ' ] = 0.0 ;
210
215
}
211
216
217
+ $ info ['debug ' ] ??= '' ;
212
218
rewind ($ this ->debugBuffer );
213
- $ info ['debug ' ] = stream_get_contents ($ this ->debugBuffer );
219
+ if (fstat ($ this ->debugBuffer )['size ' ]) {
220
+ $ info ['debug ' ] .= stream_get_contents ($ this ->debugBuffer );
221
+ rewind ($ this ->debugBuffer );
222
+ ftruncate ($ this ->debugBuffer , 0 );
223
+ }
214
224
$ waitFor = curl_getinfo ($ this ->handle , \CURLINFO_PRIVATE );
215
225
216
226
if ('H ' !== $ waitFor [0 ] && 'C ' !== $ waitFor [0 ]) {
217
227
curl_setopt ($ this ->handle , \CURLOPT_VERBOSE , false );
218
- rewind ($ this ->debugBuffer );
219
- ftruncate ($ this ->debugBuffer , 0 );
220
228
$ this ->finalInfo = $ info ;
221
229
}
222
230
}
0 commit comments