Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Curl.php

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\Retrievers

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal