|
16 | 16 | use Symfony\Component\HttpClient\Chunk\InformationalChunk; |
17 | 17 | use Symfony\Component\HttpClient\Exception\TransportException; |
18 | 18 | use Symfony\Component\HttpClient\Internal\CurlClientState; |
| 19 | +use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface; |
19 | 20 | use Symfony\Contracts\HttpClient\ResponseInterface; |
20 | 21 |
|
21 | 22 | /** |
@@ -113,7 +114,7 @@ public function __construct(CurlClientState $multi, $ch, array $options = null, |
113 | 114 | $this->initializer = static function (self $response) { |
114 | 115 | $waitFor = curl_getinfo($ch = $response->handle, CURLINFO_PRIVATE); |
115 | 116 |
|
116 | | - return 'H' === $waitFor[0] || 'D' === $waitFor[0]; |
| 117 | + return 'H' === $waitFor[0]; |
117 | 118 | }; |
118 | 119 |
|
119 | 120 | // Schedule the request in a non-blocking way |
@@ -174,17 +175,15 @@ public function __destruct() |
174 | 175 | return; // Unused pushed response |
175 | 176 | } |
176 | 177 |
|
177 | | - $waitFor = curl_getinfo($this->handle, CURLINFO_PRIVATE); |
178 | | - |
179 | | - if ('C' === $waitFor[0] || '_' === $waitFor[0]) { |
180 | | - $this->close(); |
181 | | - } elseif ('H' === $waitFor[0]) { |
182 | | - $waitFor[0] = 'D'; // D = destruct |
183 | | - curl_setopt($this->handle, CURLOPT_PRIVATE, $waitFor); |
184 | | - } |
185 | | - |
| 178 | + $e = null; |
186 | 179 | $this->doDestruct(); |
| 180 | + } catch (HttpExceptionInterface $e) { |
| 181 | + throw $e; |
187 | 182 | } finally { |
| 183 | + if (null !== $e) { |
| 184 | + throw $e; |
| 185 | + } |
| 186 | + |
188 | 187 | $this->close(); |
189 | 188 |
|
190 | 189 | if (!$this->multi->openHandles) { |
@@ -304,7 +303,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array & |
304 | 303 | { |
305 | 304 | $waitFor = @curl_getinfo($ch, CURLINFO_PRIVATE) ?: '_0'; |
306 | 305 |
|
307 | | - if ('H' !== $waitFor[0] && 'D' !== $waitFor[0]) { |
| 306 | + if ('H' !== $waitFor[0]) { |
308 | 307 | return \strlen($data); // Ignore HTTP trailers |
309 | 308 | } |
310 | 309 |
|
@@ -370,7 +369,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array & |
370 | 369 | // Headers and redirects completed, time to get the response's content |
371 | 370 | $multi->handlesActivity[$id][] = new FirstChunk(); |
372 | 371 |
|
373 | | - if ('D' === $waitFor[0] || 'HEAD' === $info['http_method'] || \in_array($statusCode, [204, 304], true)) { |
| 372 | + if ('HEAD' === $info['http_method'] || \in_array($statusCode, [204, 304], true)) { |
374 | 373 | $waitFor = '_0'; // no content expected |
375 | 374 | $multi->handlesActivity[$id][] = null; |
376 | 375 | $multi->handlesActivity[$id][] = null; |
|
0 commit comments