You are here

class FeedsHTTPFetcherResult in Feeds 7.2

Result of FeedsHTTPFetcher::fetch().

Hierarchy

Expanded class hierarchy of FeedsHTTPFetcherResult

File

plugins/FeedsHTTPFetcher.inc, line 13

View source
class FeedsHTTPFetcherResult extends FeedsFetcherResult {

  /**
   * The URL of the feed being fetched.
   *
   * @var string
   */
  protected $url;

  /**
   * The timeout in seconds to wait for a download.
   *
   * @var int
   */
  protected $timeout;

  /**
   * Whether to ignore SSL validation errors.
   *
   * @var bool
   */
  protected $acceptInvalidCert;

  /**
   * Whether to cache the HTTP result.
   *
   * @var bool
   */
  protected $cacheHttpResult;

  /**
   * Constructor.
   */
  public function __construct($url = NULL) {
    $this->url = $url;
  }

  /**
   * Overrides FeedsFetcherResult::getRaw().
   *
   * @throws FeedsHTTPRequestException
   *   In case the result code of the HTTP request is not in the 2xx series.
   */
  public function getRaw() {
    if ($this
      ->rawExists()) {
      return parent::getRaw();
    }

    // Include HTTP functions.
    feeds_include_library('http_request.inc', 'http_request');

    // Try to fetch the data from a URL.
    $result = feeds_http_request($this->url, array(
      'accept_invalid_cert' => $this->acceptInvalidCert,
      'timeout' => $this->timeout,
      'cache_http_result' => $this->cacheHttpResult,
    ));
    http_request_check_result($this->url, $result);
    $this->raw = $result->data;
    return $this
      ->sanitizeRawOptimized($this->raw);
  }

  /**
   * Returns the configured value for the request timeout option.
   *
   * @return int
   *   Timeout in seconds to wait for an HTTP get request to finish.
   */
  public function getTimeout() {
    return $this->timeout;
  }

  /**
   * Sets the request timeout option.
   *
   * @param int $timeout
   *   Timeout in seconds to wait for an HTTP get request to finish.
   */
  public function setTimeout($timeout) {
    $this->timeout = $timeout;
  }

  /**
   * Sets the accept invalid certificates option.
   *
   * @param bool $accept_invalid_cert
   *   Whether to accept invalid certificates.
   */
  public function setAcceptInvalidCert($accept_invalid_cert) {
    $this->acceptInvalidCert = (bool) $accept_invalid_cert;
  }

  /**
   * Sets the cache HTTP results of request option.
   *
   * @param bool $cache_http_result
   *   Whether to cache the HTTP result.
   */
  public function setCacheHttpResult($cache_http_result) {
    $this->cacheHttpResult = (bool) $cache_http_result;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsFetcherResult::$file_path protected property The path to a file where the raw data is stored.
FeedsFetcherResult::$raw protected property The raw fetched data.
FeedsFetcherResult::checkFile protected function Checks that a file exists and is readable.
FeedsFetcherResult::constructFilePath public function Constructs file name for saving the raw data.
FeedsFetcherResult::fileExists public function Returns if the file to parse exists.
FeedsFetcherResult::getFeedsInProgressDir public function Returns directory for storing files that are in progress of import.
FeedsFetcherResult::getFileContents public function Returns the contents of a file, if it exists.
FeedsFetcherResult::getFilePath public function Get a path to a temporary file containing the resource provided by the fetcher. 1
FeedsFetcherResult::rawExists public function Returns if raw data exists.
FeedsFetcherResult::sanitizeFile public function Sanitize the file in place.
FeedsFetcherResult::sanitizeRaw public function Sanitize the raw content string.
FeedsFetcherResult::sanitizeRawOptimized public function Sanitize the raw content string.
FeedsFetcherResult::saveRawToFile public function Saves the raw fetcher result to a file.
FeedsFetcherResult::__sleep public function Prevent saving the raw result when serializing object.
FeedsHTTPFetcherResult::$acceptInvalidCert protected property Whether to ignore SSL validation errors.
FeedsHTTPFetcherResult::$cacheHttpResult protected property Whether to cache the HTTP result.
FeedsHTTPFetcherResult::$timeout protected property The timeout in seconds to wait for a download.
FeedsHTTPFetcherResult::$url protected property The URL of the feed being fetched.
FeedsHTTPFetcherResult::getRaw public function Overrides FeedsFetcherResult::getRaw(). Overrides FeedsFetcherResult::getRaw
FeedsHTTPFetcherResult::getTimeout public function Returns the configured value for the request timeout option.
FeedsHTTPFetcherResult::setAcceptInvalidCert public function Sets the accept invalid certificates option.
FeedsHTTPFetcherResult::setCacheHttpResult public function Sets the cache HTTP results of request option.
FeedsHTTPFetcherResult::setTimeout public function Sets the request timeout option.
FeedsHTTPFetcherResult::__construct public function Constructor. Overrides FeedsFetcherResult::__construct