Update UrlRequests with patch, admin test page for it
Also update delete to have optional body (content)
This commit is contained in:
35
www/admin/UrlReqeusts.target.php
Normal file
35
www/admin/UrlReqeusts.target.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
// url requests target test
|
||||
require 'config.php';
|
||||
use CoreLibs\Convert\Json;
|
||||
$LOG_FILE_ID = 'classTest-urlrequests-target';
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$http_headers = array_filter($_SERVER, function ($value, $key) {
|
||||
if (str_starts_with($key, 'HTTP_')) {
|
||||
return true;
|
||||
}
|
||||
}, ARRAY_FILTER_USE_BOTH);
|
||||
|
||||
$file_get = file_get_contents('php://input');
|
||||
// str_replace('\"', '"', trim($file_get, '"'));
|
||||
|
||||
$log->debug('SERVER', $log->prAr($_SERVER));
|
||||
$log->debug('HEADERS', $log->prAr($http_headers));
|
||||
$log->debug('POST', $log->prAr($_POST));
|
||||
$log->debug('PHP-INPUT', $log->prAr($file_get));
|
||||
|
||||
print Json::jsonConvertArrayTo([
|
||||
'HTTP_HEADERS' => $http_headers,
|
||||
"_GET" => $_GET,
|
||||
"_POST" => Json::jsonConvertToArray($file_get),
|
||||
]);
|
||||
|
||||
$log->debug('[END]', '=========================================>');
|
||||
|
||||
// __END__
|
||||
@@ -35,13 +35,88 @@ print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$url = 'https://soba.egplusww.jp';
|
||||
|
||||
$data = $client->requestGet($url, []);
|
||||
print "<hr>";
|
||||
$data = $client->requestGet(
|
||||
'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlReqeusts.target.php'
|
||||
. '?other=get_a',
|
||||
['test-header: ABC', 'request-type: _GET'],
|
||||
['foo' => 'BAR']
|
||||
);
|
||||
print "_GET RESPONSE: <pre>" . print_r($data, true) . "</pre>";
|
||||
|
||||
print "<hr>";
|
||||
print "RESPONSE: <pre>" . print_r($data, true) . "</pre>";
|
||||
$data = $client->requestPost(
|
||||
'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlReqeusts.target.php'
|
||||
. '?other=post_a',
|
||||
['payload' => 'data post'],
|
||||
[
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
'test-header: ABC',
|
||||
'info-request-type: _POST'
|
||||
],
|
||||
['foo' => 'BAR post'],
|
||||
);
|
||||
print "_POST RESPONSE: <pre>" . print_r($data, true) . "</pre>";
|
||||
|
||||
print "<hr>";
|
||||
$data = $client->requestPut(
|
||||
'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlReqeusts.target.php'
|
||||
. '?other=put_a',
|
||||
['payload' => 'data put'],
|
||||
[
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
'test-header: ABC',
|
||||
'info-request-type: _PUT'
|
||||
],
|
||||
['foo' => 'BAR put'],
|
||||
);
|
||||
print "_PUT RESPONSE: <pre>" . print_r($data, true) . "</pre>";
|
||||
|
||||
print "<hr>";
|
||||
$data = $client->requestPatch(
|
||||
'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlReqeusts.target.php'
|
||||
. '?other=patch_a',
|
||||
['payload' => 'data patch'],
|
||||
[
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
'test-header: ABC',
|
||||
'info-request-type: _PATCH'
|
||||
],
|
||||
['foo' => 'BAR patch'],
|
||||
);
|
||||
print "_PATCH RESPONSE: <pre>" . print_r($data, true) . "</pre>";
|
||||
|
||||
print "<hr>";
|
||||
$data = $client->requestDelete(
|
||||
'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlReqeusts.target.php'
|
||||
. '?other=delete_no_body_a',
|
||||
null,
|
||||
[
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
'test-header: ABC',
|
||||
'info-request-type: _DELETE'
|
||||
],
|
||||
['foo' => 'BAR delete'],
|
||||
);
|
||||
print "_DELETE RESPONSE: <pre>" . print_r($data, true) . "</pre>";
|
||||
$data = $client->requestDelete(
|
||||
'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlReqeusts.target.php'
|
||||
. '?other=delete_body_a',
|
||||
['payload' => 'data delete'],
|
||||
[
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
'test-header: ABC',
|
||||
'info-request-type: _DELETE'
|
||||
],
|
||||
['foo' => 'BAR delete'],
|
||||
);
|
||||
print "_DELETE RESPONSE: <pre>" . print_r($data, true) . "</pre>";
|
||||
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user