function Curl::retrieve
Overrides UriRetrieverInterface::retrieve
See also
\JsonSchema\Uri\Retrievers\UriRetrieverInterface::retrieve()
File
-
vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Uri/ Retrievers/ Curl.php, line 37
Class
- Curl
- Tries to retrieve JSON schemas from a URI using cURL library
Namespace
JsonSchema\Uri\RetrieversCode
public function retrieve($uri) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: ' . Validator::SCHEMA_MEDIA_TYPE,
));
$response = curl_exec($ch);
if (false === $response) {
throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
}
$this->fetchMessageBody($response);
$this->fetchContentType($response);
curl_close($ch);
return $this->messageBody;
}