wppaste
WordPress

FileClient

Source
wp-includes/SimplePie/src/HTTP/FileClient.php:21
HTTP Client based on \SimplePie\File

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 3 of the 5 tracked releases.

Properties · 2

$registrySimplePie\Registryprivate
$optionsSimplePie\HTTP\array{timeout?:private

Methods · 2

Source code

final class FileClient implements Client{    /** @var Registry */    private $registry;     /** @var array{timeout?: int, redirects?: int, useragent?: string, force_fsockopen?: bool, curl_options?: array<mixed>} */    private $options;     /**     * @param array{timeout?: int, redirects?: int, useragent?: string, force_fsockopen?: bool, curl_options?: array<mixed>} $options     */    public function __construct(Registry $registry, array $options = [])    {        $this->registry = $registry;        $this->options = $options;    }     /**     * send a request and return the response     *     * @param Client::METHOD_* $method     * @param array<string, string> $headers     *     * @throws ClientException if anything goes wrong requesting the data     */    public function request(string $method, string $url, array $headers = []): Response    {        // @phpstan-ignore-next-line Enforce PHPDoc type.        if ($method !== self::METHOD_GET) {            throw new InvalidArgumentException(sprintf(                '%s(): Argument #1 ($method) only supports method "%s".',                __METHOD__,                self::METHOD_GET            ), 1);        }         try {            $file = $this->registry->create(File::class, [                $url,                $this->options['timeout'] ?? 10,                $this->options['redirects'] ?? 5,                $headers,                $this->options['useragent'] ?? Misc::get_default_useragent(),                $this->options['force_fsockopen'] ?? false,                $this->options['curl_options'] ?? []            ]);        } catch (Throwable $th) {            throw new ClientException($th->getMessage(), $th->getCode(), $th);        }         if ($file->error !== null && $file->get_status_code() === 0) {            throw new ClientException($file->error);        }         return $file;    }}

Changelog

Unchanged from 6.9.7 through 7.1.0.

  1. 6.9.7
  2. 7.0.4
  3. 7.1.0

Signature, return type and hooks compared across 3 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/SimplePie/src/HTTP/FileClient.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.