8000 [HttpClient] Forbid and empty HTTP method · symfony/symfony@839fe6b · GitHub
[go: up one dir, main page]

Skip to content

Commit 839fe6b

Browse files
committed
[HttpClient] Forbid and empty HTTP method
1 parent 366d509 commit 839fe6b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/HttpClient/HttpClientTrait.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ trait HttpClientTrait
3434
*/
3535
private static function prepareRequest(?string $method, ?string $url, array $options, array $defaultOptions = [], bool $allowExtraOptions = false): array
3636
{
37-
if (null !== $method && \strlen($method) !== strspn($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')) {
38-
throw new InvalidArgumentException(sprintf('Invalid HTTP method "%s", only uppercase letters are accepted.', $method));
37+
38+
if (null !== $method) {
39+
if (\strlen($method) !== strspn($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')) {
40+
throw new InvalidArgumentException(sprintf('Invalid HTTP method "%s", only uppercase letters are accepted.', $method));
41+
}
42+
if (!$method) {
43+
throw new InvalidArgumentException('The HTTP method can not be empty.');
44+
}
3945
}
4046

4147
$options = self::mergeDefaultOptions($options, $defaultOptions, $allowExtraOptions);

0 commit comments

Comments
 (0)
0