Skip to content

Commit 7b8e2f6

Browse files
committed
refactor: applied recommendation changes
1 parent f33d9e6 commit 7b8e2f6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

system/HTTP/CURLRequest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,10 @@ protected function applyMethod(string $method, array $curlOptions): array
469469
*/
470470
protected function applyBody(array $curlOptions = []): array
471471
{
472-
if ($this->body !== '' && $this->body !== null) {
473-
$curlOptions[CURLOPT_POSTFIELDS] = (string) $this->getBody();
472+
$requestBody = (string) $this->getBody();
473+
474+
if ($requestBody !== '') {
475+
$curlOptions[CURLOPT_POSTFIELDS] = $requestBody;
474476
}
475477

476478
return $curlOptions;
@@ -529,7 +531,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
529531
}
530532

531533
// Certificate
532-
if (array_key_exists('cert', $config) && $config['cert']) {
534+
if (array_key_exists('cert', $config) && $config['cert'] !== '' || $config['cert'] !== []) {
533535
$cert = $config['cert'];
534536

535537
if (is_array($cert)) {
@@ -650,7 +652,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
650652
}
651653

652654
// version
653-
if (array_key_exists('version', $config) && $config['version']) {
655+
if (array_key_exists('version', $config) && ((is_string($config['version']) && $config['version'] !== '') || (is_numeric($config['version']) && $config['version'] !== 0))) {
654656
$version = sprintf('%.1F', $config['version']);
655657
if ($version === '1.0') {
656658
$curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;

0 commit comments

Comments
 (0)