@@ -71,7 +71,7 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
71
71
// Move the pushed response to the activity list
72
72
$ buffer = $ options ['buffer ' ];
73
73
74
- if ('headers ' !== curl_getinfo ($ ch , CURLINFO_PRIVATE )) {
74
+ if ('H ' !== curl_getinfo ($ ch , CURLINFO_PRIVATE )[ 0 ] ) {
75
75
if ($ options ['buffer ' ] instanceof \Closure) {
76
76
try {
77
77
[$ content , $ buffer ] = [null , $ content ];
@@ -249,17 +249,15 @@ public function __destruct()
249
249
*/
250
250
private function close (): void
251
251
{
252
- if (self ::$ performing ) {
253
- $ this ->multi ->handlesActivity [$ this ->id ][] = null ;
254
- $ this ->multi ->handlesActivity [$ this ->id ][] = new TransportException ('Response has been canceled. ' );
252
+ unset($ this ->multi ->openHandles [$ this ->id ], $ this ->multi ->handlesActivity [$ this ->id ]);
253
+ curl_setopt ($ this ->handle , CURLOPT_PRIVATE , '_0 ' );
255
254
255
+ if (self ::$ performing ) {
256
256
return ;
257
257
}
258
258
259
- unset($ this ->multi ->openHandles [$ this ->id ], $ this ->multi ->handlesActivity [$ this ->id ]);
260
259
curl_multi_remove_handle ($ this ->multi ->handle , $ this ->handle );
261
260
curl_setopt_array ($ this ->handle , [
262
- CURLOPT_PRIVATE => '_0 ' ,
263
261
CURLOPT_NOPROGRESS => true ,
264
262
CURLOPT_PROGRESSFUNCTION => null ,
265
263
CURLOPT_HEADERFUNCTION => null ,
@@ -432,7 +430,12 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &
432
430
if (!$ content && $ options ['buffer ' ] instanceof \Closure && $ content = $ options ['buffer ' ]($ headers ) ?: null ) {
433
431
$ content = \is_resource ($ content ) ? $ content : fopen ('php://temp ' , 'w+ ' );
434
432
}
433
+
434
+ if (null !== $ info ['error ' ]) {
435
+ throw new TransportException ($ info ['error ' ]);
436
+ }
435
437
} catch (\Throwable $ e ) {
438
+ $ multi ->handlesActivity [$ id ] = $ multi ->handlesActivity [$ id ] ?? [new FirstChunk ()];
436
439
$ multi ->handlesActivity [$ id ][] = null ;
437
440
$ multi ->handlesActivity [$ id ][] = $ e ;
438
441
0 commit comments