From 3c5200cd99923439d4f601872e80e03b3aa5568b Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 21 Oct 2024 09:32:20 +0900 Subject: [PATCH] Test run for Curl URL Requests --- www/admin/class_test.php | 1 + ....url-requests.php => class_test.url-requests.curl.php} | 4 ++++ www/lib/CoreLibs/UrlRequests/Curl.php | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) rename www/admin/{class_test.url-requests.php => class_test.url-requests.curl.php} (91%) diff --git a/www/admin/class_test.php b/www/admin/class_test.php index 315effd3..6c173f18 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -117,6 +117,7 @@ $test_files = [ 'class_test.config.direct.php' => 'Class Test: CONFIG DIRECT', 'class_test.class-calls.php' => 'Class Test: CLASS CALLS', 'class_test.error_msg.php' => 'Class Test: ERROR MSG', + 'class_test.url-requests.curl.php' => 'Class Test: URL REQUESTS: CURL', 'subfolder/class_test.config.direct.php' => 'Class Test: CONFIG DIRECT SUB', ]; diff --git a/www/admin/class_test.url-requests.php b/www/admin/class_test.url-requests.curl.php similarity index 91% rename from www/admin/class_test.url-requests.php rename to www/admin/class_test.url-requests.curl.php index 94d64614..d34a85d6 100644 --- a/www/admin/class_test.url-requests.php +++ b/www/admin/class_test.url-requests.curl.php @@ -39,6 +39,10 @@ $url = 'https://soba.egplusww.jp'; $data = $client->requestGet($url, []); +print "
"; +print "RESPONSE:
" . print_r($data, true) . "
"; +print "
"; + print ""; // __END__ diff --git a/www/lib/CoreLibs/UrlRequests/Curl.php b/www/lib/CoreLibs/UrlRequests/Curl.php index 73e013ab..6e088c4e 100644 --- a/www/lib/CoreLibs/UrlRequests/Curl.php +++ b/www/lib/CoreLibs/UrlRequests/Curl.php @@ -139,9 +139,7 @@ class Curl implements Interface\RequestsInterface // init curl handle $handle = $this->handleCurleInit($url); // set the standard curl options - if ($headers !== []) { - $this->setCurlOptions($handle, $headers); - } + $this->setCurlOptions($handle, $headers); // for post we set POST option if ($type == "post") { curl_setopt($handle, CURLOPT_POST, true); @@ -205,7 +203,9 @@ class Curl implements Interface\RequestsInterface if (!empty($this->auth_ident)) { curl_setopt($handle, CURLOPT_USERPWD, $this->auth_ident); } - curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); + if ($headers !== []) { + curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); + } // curl_setopt($handle, CURLOPT_FAILONERROR, true); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); // for debug only