Skip to content

Commit

Permalink
refactor: applied recommendation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr committed Dec 6, 2024
1 parent f33d9e6 commit 7b8e2f6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions system/HTTP/CURLRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,10 @@ protected function applyMethod(string $method, array $curlOptions): array
*/
protected function applyBody(array $curlOptions = []): array
{
if ($this->body !== '' && $this->body !== null) {
$curlOptions[CURLOPT_POSTFIELDS] = (string) $this->getBody();
$requestBody = (string) $this->getBody();

if ($requestBody !== '') {
$curlOptions[CURLOPT_POSTFIELDS] = $requestBody;
}

return $curlOptions;
Expand Down Expand Up @@ -529,7 +531,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
}

// Certificate
if (array_key_exists('cert', $config) && $config['cert']) {
if (array_key_exists('cert', $config) && $config['cert'] !== '' || $config['cert'] !== []) {
$cert = $config['cert'];

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

// version
if (array_key_exists('version', $config) && $config['version']) {
if (array_key_exists('version', $config) && ((is_string($config['version']) && $config['version'] !== '') || (is_numeric($config['version']) && $config['version'] !== 0))) {
$version = sprintf('%.1F', $config['version']);
if ($version === '1.0') {
$curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
Expand Down

0 comments on commit 7b8e2f6

Please sign in to comment.