Changeset View
Changeset View
Standalone View
Standalone View
include/network/HTTPRequest.php
Show First 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | if( $args['wait'] ) { | ||||
$args['wait'] | $args['wait'] | ||||
) ); | ) ); | ||||
usleep( $args['wait'] * 1000000 ); | usleep( $args['wait'] * 1000000 ); | ||||
} | } | ||||
// URL | // URL | ||||
curl_setopt( $curl, CURLOPT_URL, $url ); | curl_setopt( $curl, CURLOPT_URL, $url ); | ||||
// internal cURL shit to do not show the result as output but return it | // cURL execution will return the result on success, false on failure | ||||
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); | curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); | ||||
// internal cURL shit to return headers | // internal cURL shit to return headers | ||||
curl_setopt( $curl, CURLOPT_HEADER, true ); | curl_setopt( $curl, CURLOPT_HEADER, true ); | ||||
// this contains also the headers | // this contains also the headers | ||||
$http_response_raw = curl_exec( $curl ); | $http_response_raw = curl_exec( $curl ); | ||||
// if the execution fails, then the detailed error is logged | |||||
if ($http_response_raw === false) { | |||||
Log::error("cURL error: " . curl_error($curl)); | |||||
} | |||||
// load the response with the headers | // load the response with the headers | ||||
$response = $this->loadHTTPResponseRaw( $http_response_raw ); | $response = $this->loadHTTPResponseRaw( $http_response_raw ); | ||||
// Check the HTTP status | // Check the HTTP status | ||||
$http_status = $this->getLatestHTTPResponseStatus(); | $http_status = $this->getLatestHTTPResponseStatus(); | ||||
// no status no party | // no status no party | ||||
▲ Show 20 Lines • Show All 415 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register