@@ -356,7 +356,7 @@ public function send(string $method, string $url)
356356 // Reset our curl options so we're on a fresh slate.
357357 $ curlOptions = [];
358358
359- if (! empty ( $ this ->config ['query ' ]) && is_array ($ this ->config ['query ' ])) {
359+ if (array_key_exists ( ' query ' , $ this ->config ) && $ this -> config ['query ' ] && is_array ($ this ->config ['query ' ])) {
360360 // This is likely too naive a solution.
361361 // Should look into handling when $url already
362362 // has query vars on it.
@@ -422,7 +422,7 @@ public function send(string $method, string $url)
422422 */
423423 protected function applyRequestHeaders (array $ curlOptions = []): array
424424 {
425- if (empty ( $ this ->headers ) ) {
425+ if ($ this ->headers === [] ) {
426426 return $ curlOptions ;
427427 }
428428
@@ -469,7 +469,7 @@ protected function applyMethod(string $method, array $curlOptions): array
469469 */
470470 protected function applyBody (array $ curlOptions = []): array
471471 {
472- if (! empty ( $ this ->body ) ) {
472+ if ($ this -> body !== '' && $ this ->body !== null ) {
473473 $ curlOptions [CURLOPT_POSTFIELDS ] = (string ) $ this ->getBody ();
474474 }
475475
@@ -518,18 +518,18 @@ protected function setResponseHeaders(array $headers = [])
518518 protected function setCURLOptions (array $ curlOptions = [], array $ config = [])
519519 {
520520 // Auth Headers
521- if (! empty ( $ config ['auth ' ]) ) {
521+ if (array_key_exists ( ' auth ' , $ config) && $ config ['auth ' ]) {
522522 $ curlOptions [CURLOPT_USERPWD ] = $ config ['auth ' ][0 ] . ': ' . $ config ['auth ' ][1 ];
523523
524- if (! empty ( $ config ['auth ' ][ 2 ]) && strtolower ($ config ['auth ' ][2 ]) === 'digest ' ) {
524+ if (array_key_exists ( 2 , $ config ['auth ' ]) && $ config [ ' auth ' ][ 2 ] && strtolower ($ config ['auth ' ][2 ]) === 'digest ' ) {
525525 $ curlOptions [CURLOPT_HTTPAUTH ] = CURLAUTH_DIGEST ;
526526 } else {
527527 $ curlOptions [CURLOPT_HTTPAUTH ] = CURLAUTH_BASIC ;
528528 }
529529 }
530530
531531 // Certificate
532- if (! empty ( $ config ['cert ' ]) ) {
532+ if (array_key_exists ( ' cert ' , $ config) && $ config ['cert ' ]) {
533533 $ cert = $ config ['cert ' ];
534534
535535 if (is_array ($ cert )) {
@@ -575,7 +575,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
575575 }
576576
577577 // Decode Content
578- if (! empty ( $ config ['decode_content ' ]) ) {
578+ if (array_key_exists ( ' decode_content ' , $ config) && $ config ['decode_content ' ]) {
579579 $ accept = $ this ->getHeaderLine ('Accept-Encoding ' );
580580
581581 if ($ accept !== '' ) {
@@ -621,7 +621,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
621621 $ curlOptions [CURLOPT_CONNECTTIMEOUT_MS ] = (float ) $ config ['connect_timeout ' ] * 1000 ;
622622
623623 // Post Data - application/x-www-form-urlencoded
624- if (! empty ( $ config ['form_params ' ]) && is_array ($ config ['form_params ' ])) {
624+ if (array_key_exists ( ' form_params ' , $ config) && $ config ['form_params ' ] && is_array ($ config ['form_params ' ])) {
625625 $ postFields = http_build_query ($ config ['form_params ' ]);
626626 $ curlOptions [CURLOPT_POSTFIELDS ] = $ postFields ;
627627
@@ -632,7 +632,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
632632 }
633633
634634 // Post Data - multipart/form-data
635- if (! empty ( $ config ['multipart ' ]) && is_array ($ config ['multipart ' ])) {
635+ if (array_key_exists ( ' multipart ' , $ config) && $ config ['multipart ' ] && is_array ($ config ['multipart ' ])) {
636636 // setting the POSTFIELDS option automatically sets multipart
637637 $ curlOptions [CURLOPT_POSTFIELDS ] = $ config ['multipart ' ];
638638 }
@@ -650,7 +650,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
650650 }
651651
652652 // version
653- if (! empty ( $ config ['version ' ]) ) {
653+ if (array_key_exists ( ' version ' , $ config) && $ config ['version ' ]) {
654654 $ version = sprintf ('%.1F ' , $ config ['version ' ]);
655655 if ($ version === '1.0 ' ) {
656656 $ curlOptions [CURLOPT_HTTP_VERSION ] = CURL_HTTP_VERSION_1_0 ;
0 commit comments