Skip to content

Commit 917a8d9

Browse files
committed
[HttpClient] fix bufferRegex declaration
1 parent 751f5d5 commit 917a8d9

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

src/Symfony/Component/HttpClient/HttpClientTrait.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ private static function prepareRequest(?string $method, ?string $url, array $opt
4444

4545
if (\is_string($options['buffer'] ?? null) && false === @preg_match($options['buffer'], '')) {
4646
throw new InvalidArgumentException('Option "buffer" should be a valid regular expression.');
47-
// try {
48-
// preg_match($options['buffer'], '');
49-
// } catch (\Exception $exception) {
50-
// }
5147
}
5248

5349
if (isset($options['json'])) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
7070
rewind($content);
7171
$multi->handlesActivity[$id][] = stream_get_contents($content);
7272
}
73-
$content = isset($options['buffer']) && true === $options['buffer'] ? $content : null;
73+
$content = ($options['buffer'] ?? true) && !\is_string($options['buffer'] ?? true) ? $content : null;
7474
}
7575

7676
curl_setopt($ch, CURLOPT_HEADERFUNCTION, static function ($ch, string $data) use (&$info, &$headers, $options, $multi, $id, &$location, $resolveRedirect, $logger, &$content): int {
@@ -345,7 +345,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &
345345
return 0;
346346
}
347347

348-
if (isset($headers['content-type'], $options['buffer']) && \is_string($options['buffer'] ?? null) && null === $content) {
348+
if (isset($headers['content-type'], $options['buffer']) && \is_string($options['buffer'] ?? null) && !$content) {
349349
$content = self::createBufferForContentType($headers['content-type'][0], $options['buffer']);
350350
}
351351

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(NativeClientState $multi, $context, string $url, $op
5252
$this->resolveRedirect = $resolveRedirect;
5353
$this->onProgress = $onProgress;
5454
$this->content = ($options['buffer'] ?? true) && !\is_string($options['buffer'] ?? true) ? fopen('php://temp', 'w+') : null;
55-
$this->bufferRegex = \is_string($options['buffer'] ?? null);
55+
$this->bufferRegex = \is_string($options['buffer'] ?? null) ? $options['buffer'] : null;
5656

5757
// Temporary resources to dechunk/inflate the response stream
5858
$this->buffer = fopen('php://temp', 'w+');
@@ -154,7 +154,7 @@ private function open(): void
154154
stream_set_blocking($h, false);
155155
$this->context = $this->resolveRedirect = null;
156156

157-
if ($this->bufferRegex && isset($this->headers['content-type']) && null === $this->content) {
157+
if (null !== $this->bufferRegex && isset($this->headers['content-type']) && null === $this->content) {
158158
$this->content = self::createBufferForContentType($this->headers['content-type'][0], $this->bufferRegex);
159159
}
160160

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy