8000 bug #34255 [HttpClient] fix after merge from 4.3 (nicolas-grekas) · symfony/symfony@62bf1f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 62bf1f5

Browse files
bug #34255 [HttpClient] fix after merge from 4.3 (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpClient] fix after merge from 4.3 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- 3c6dc96 [HttpClient] fix after merge from 4.3
2 parents 3932642 + 3c6dc96 commit 62bf1f5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function request(string $method, string $url, array $options = []): Respo
170170
}
171171

172172
if (!\is_string($options['auth_ntlm'])) {
173-
throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must be string or an array, %s given.', \gettype($options['auth_ntlm'])));
173+
throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must be a string or an array, %s given.', \gettype($options['auth_ntlm'])));
174174
}
175175

176176
$curlopts[CURLOPT_USERPWD] = $options['auth_ntlm'];

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
7171
// Move the pushed response to the activity list
7272
$buffer = $options['buffer'];
7373

74-
if ('headers' !== curl_getinfo($ch, CURLINFO_PRIVATE)) {
74+
if ('H' !== curl_getinfo($ch, CURLINFO_PRIVATE)[0]) {
7575
if ($options['buffer'] instanceof \Closure) {
7676
try {
7777
[$content, $buffer] = [null, $content];
@@ -249,17 +249,15 @@ public function __destruct()
249249
*/
250250
private function close(): void
251251
{
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');
255254

255+
if (self::$performing) {
256256
return;
257257
}
258258

259-
unset($this->multi->openHandles[$this->id], $this->multi->handlesActivity[$this->id]);
260259
curl_multi_remove_handle($this->multi->handle, $this->handle);
261260
curl_setopt_array($this->handle, [
262-
CURLOPT_PRIVATE => '_0',
263261
CURLOPT_NOPROGRESS => true,
264262
CURLOPT_PROGRESSFUNCTION => null,
265263
8000 CURLOPT_HEADERFUNCTION => null,
@@ -432,7 +430,12 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &
432430
if (!$content && $options['buffer'] instanceof \Closure && $content = $options['buffer']($headers) ?: null) {
433431
$content = \is_resource($content) ? $content : fopen('php://temp', 'w+');
434432
}
433+
434+
if (null !== $info['error']) {
435+
throw new TransportException($info['error']);
436+
}
435437
} catch (\Throwable $e) {
438+
$multi->handlesActivity[$id] = $multi->handlesActivity[$id] ?? [new FirstChunk()];
436439
$multi->handlesActivity[$id][] = null;
437440
$multi->handlesActivity[$id][] = $e;
438441

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ private function open(): void
181181
$this->content = \is_resource($this->content) ? $this->content : fopen('php://temp', 'w+');
182182
}
183183

184-
if (!$this->buffer) {
185-
throw new TransportException('Response has been canceled.');
184+
if (null !== $this->info['error']) {
185+
throw new TransportException($this->info['error']);
186186
}
187187
} catch (\Throwable $e) {
188188
$this->close();

0 commit comments

Comments
 (0)
0