Test run for Curl URL Requests

This commit is contained in:
Clemens Schwaighofer
2024-10-21 09:32:20 +09:00
parent 50a4b88f55
commit 3c5200cd99
3 changed files with 9 additions and 4 deletions

View File

@@ -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',
];

View File

@@ -39,6 +39,10 @@ $url = 'https://soba.egplusww.jp';
$data = $client->requestGet($url, []);
print "<hr>";
print "RESPONSE: <pre>" . print_r($data, true) . "</pre>";
print "<hr>";
print "</body></html>";
// __END__

View File

@@ -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