BASE . LOG, 'log_file_id' => $LOG_FILE_ID, 'log_per_date' => true, ]); $PAGE_NAME = 'TEST CLASS: URL REQUESTS CURL'; print ""; print "" . $PAGE_NAME . ""; print ""; print '
Class Test Master
'; print '

' . $PAGE_NAME . '

'; $client = new Curl(); print "
"; $data = $client->get( 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=get_a', [ 'headers' => [ 'test-header' => 'ABC', 'info-request-type' => '_GET', 'Funk-pop' => 'Semlly god' ], 'query' => ['foo' => 'BAR'] ] ); print "_GET RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->request( 'get', 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=get_a', ); print "_GET RESPONSE, nothing set:
" . print_r($data, true) . "
"; print "
"; try { $data = $client->request( 'get', 'soba54.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=get_a', ); print "_GET RESPONSE, nothing set, invalid URL:
" . print_r($data, true) . "
"; } catch (Exception $e) { print "Exception:
" . print_r($e, true) . "

"; } print "
"; $data = $client->request( "get", 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/' . 'trunk/www/admin/UrlRequests.target.php' . '?other=get_a', [ "headers" => [ 'test-header' => 'ABC', 'info-request-type' => '_GET', 'Funk-pop' => 'Semlly god' ], "query" => ['foo' => 'BAR'], ], ); print "[request] _GET RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->post( 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=post_a', [ 'body' => ['payload' => 'data post'], 'headers' => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'test-header' => 'ABC', 'info-request-type' => '_POST', ], 'query' => ['foo' => 'BAR post'], ] ); print "_POST RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->request( "post", 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=post_a', [ "body" => ['payload' => 'data post', 'request' => 'I am the request body'], "headers" => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'test-header' => 'ABC', 'info-request-type' => '_POST', ], "query" => ['foo' => 'BAR post'], ] ); print "[request] _POST RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->request( "post", 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=post_a', [ "body" => 'string body here', "headers" => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'test-header' => 'ABC', 'info-request-type' => '_POST', ], "query" => ['foo' => 'BAR post'], ] ); print "[request|string body] _POST RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->put( 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=put_a', [ "body" => ['payload' => 'data put'], "headers" => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'test-header' => 'ABC', 'info-request-type' => '_PUT', ], 'query' => ['foo' => 'BAR put'], ] ); print "_PUT RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->patch( 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=patch_a', [ "body" => ['payload' => 'data patch'], "headers" => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'test-header' => 'ABC', 'info-request-type' => '_PATCH', ], 'query' => ['foo' => 'BAR patch'], ] ); print "_PATCH RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->delete( 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=delete_no_body_a', [ "body" => null, "headers" => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'test-header' => 'ABC', 'info-request-type' => '_DELETE', ], "query" => ['foo' => 'BAR delete'], ] ); print "_DELETE RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->delete( 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=delete_body_a', [ "body" => ['payload' => 'data delete'], "headers" => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'test-header' => 'ABC', 'info-request-type' => '_DELETE', ], "query" => ['foo' => 'BAR delete'], ] ); print "_DELETE RESPONSE BODY:
" . print_r($data, true) . "
"; print "
"; try { $uc = new Curl([ "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/foo', "headers" => [ 'DEFAULT-master' => 'master-header', 'default-header' => 'uc-get', 'default-remove' => 'will be removed', 'default-remove-array' => ['a', 'b'], 'default-remove-array-part' => ['c', 'd'], 'default-remove-array-part-alt' => ['c', 'd', 'e'], 'default-overwrite' => 'will be overwritten', 'default-add' => 'will be added', ], 'query' => [ 'global-p' => 'glob' ] ]); print "CONFIG:
" . print_r($uc->getConfig(), true) . "
"; $uc->removeHeaders(['default-remove' => '']); $uc->removeHeaders(['default-remove-array' => ['a', 'b']]); $uc->removeHeaders(['default-remove-array-part' => 'c']); $uc->removeHeaders(['default-remove-array-part-alt' => ['c', 'd']]); $uc->setHeaders(['default-new' => 'Something new']); $uc->setHeaders(['default-overwrite' => 'Something Overwritten']); $uc->setHeaders(['default-add' => 'Something Added'], true); print "CONFIG:
" . print_r($uc->getConfig(), true) . "
"; $data = $uc->request( 'get', 'UrlRequests.target.php', [ 'headers' => [ 'call-header' => 'call-get', 'default-header' => 'overwrite-uc-get', 'X-Foo' => ['bar', 'baz'], ], 'query' => [ 'other' => 'get_a', ], ] ); print "[uc] _GET RESPONSE, nothing set:
" . print_r($data, true) . "
"; print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; } catch (Exception $e) { print "Exception:
" . print_r(json_decode($e->getMessage(), true), true) . "

"; } print "
"; try { $uc = new Curl([ "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/', "http_errors" => false, "headers" => [ "Authorization" => "schmalztiegel", "RunAuthTest" => "yes", ] ]); $response = $uc->get('UrlRequests.target.php'); print "AUTH REQUEST:
" . print_r($response, true) . "
"; print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; } catch (Exception $e) { print "Exception:
" . print_r(json_decode($e->getMessage(), true), true) . "

"; } print "AUTH REQUEST WITH EXCEPTION:
"; try { $uc = new Curl([ "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/', "http_errors" => true, "headers" => [ "Authorization" => "schmalztiegel", "RunAuthTest" => "yes", ] ]); $response = $uc->get('UrlRequests.target.php'); print "AUTH REQUEST:
" . print_r($response, true) . "
"; print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; } catch (Exception $e) { print "Exception:
" . print_r(json_decode($e->getMessage(), true), true) . "

"; } print "AUTH REQUEST WITH EXCEPTION (UNSET):
"; try { $uc = new Curl([ "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/', "http_errors" => true, "headers" => [ "Authorization" => "schmalztiegel", "RunAuthTest" => "yes", ] ]); $response = $uc->get('UrlRequests.target.php', ['http_errors' => false]); print "AUTH REQUEST (UNSET):
" . print_r($response, true) . "
"; print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; } catch (Exception $e) { print "Exception:
" . print_r(json_decode($e->getMessage(), true), true) . "

"; } print "AUTH REQUEST HEADER SET:
"; try { $uc = new Curl([ "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/', "auth" => ["user", "pass", "basic"], "headers" => [ "Authorization" => "schmalztiegel", "RunAuthTest" => "yes", ] ]); $response = $uc->get('UrlRequests.target.php'); print "AUTH REQUEST (HEADER):
" . print_r($response, true) . "
"; print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; } catch (Exception $e) { print "Exception:
" . print_r(json_decode($e->getMessage(), true), true) . "

"; } print "
"; $uc = new Curl([ "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/', "headers" => [ "header-one" => "one" ] ]); $response = $uc->get('UrlRequests.target.php', ["headers" => null, "query" => ["test" => "one-test"]]); print "HEADER RESET REQUEST:
" . print_r($response, true) . "
"; print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; print "
"; $uc = new Curl([ "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/', "headers" => [ 'bar' => 'foo:bar' ] ]); $response = $uc->get('UrlRequests.target.php'); print "HEADER SET TEST REQUEST:
" . print_r($response, true) . "
"; print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; print ""; // __END__