Requests Interfaces

All interfaces defined in the Requests library.

Source files:

  • wp-includes/Requests/src/Auth.php
  • wp-includes/Requests/src/Capability.php
  • wp-includes/Requests/src/HookManager.php
  • wp-includes/Requests/src/Proxy.php
  • wp-includes/Requests/src/Transport.php

WpOrgRequestsAuth

Authentication provider interface.

Source: wp-includes/Requests/src/Auth.php
Package: RequestsAuthentication

Implement this interface to act as an authentication provider. Parameters should be passed via the constructor.

Methods

register()

php
public function register( WpOrgRequestsHooks $hooks ): void

Called by Requests::request() when an Auth instance is set as the 'auth' option. Register all needed hooks here.

Implementations

  • WpOrgRequestsAuthBasic — Basic HTTP authentication

WpOrgRequestsCapability

Capability interface declaring known transport capabilities.

Source: wp-includes/Requests/src/Capability.php
Package: RequestsUtilities

Constants

ConstantTypeValueDescription
SSLstring'ssl'Support for SSL
ALLstring[][self::SSL]Collection of all capabilities supported in Requests

This interface defines no methods — it serves as an authoritative source of queryable capability identifiers. Used by Transport::test() to check transport capabilities.


WpOrgRequestsHookManager

Event dispatcher interface.

Source: wp-includes/Requests/src/HookManager.php
Package: RequestsEventDispatcher

Methods

register()

php
public function register( string $hook, callable $callback, int $priority = 0 ): void
ParameterTypeDescription
$hookstringHook name
$callbackcallableCallback to invoke
$priorityintPriority. Negative = earlier, positive = later

dispatch()

php
public function dispatch( string $hook, array $parameters = [] ): bool
ParameterTypeDescription
$hookstringHook name
$parametersarrayParameters passed to callbacks

Returns: bool — Whether dispatching was successful.

Implementations

  • WpOrgRequestsHooks — Default hook manager

WpOrgRequestsProxy

Proxy connection interface.

Source: wp-includes/Requests/src/Proxy.php
Package: RequestsProxy
Since: 1.6

Implement this interface to handle proxy settings and authentication. Parameters should be passed via the constructor.

Methods

register()

php
public function register( WpOrgRequestsHooks $hooks ): void

Called by Requests::request() when a Proxy instance is set as the 'proxy' option. Register all needed hooks here.

Implementations

  • WpOrgRequestsProxyHttp — HTTP proxy support

WpOrgRequestsTransport

Base HTTP transport interface.

Source: wp-includes/Requests/src/Transport.php
Package: RequestsTransport

Methods

request()

Perform a single HTTP request.

php
public function request( string $url, array $headers = [], string|array $data = [], array $options = [] ): string
ParameterTypeDescription
$urlstringURL to request
$headersarrayAssociative array of request headers
$datastring|arrayPOST body or GET/HEAD URL parameters
$optionsarrayRequest options

Returns: string — Raw HTTP result.

request_multiple()

Send multiple requests simultaneously.

php
public function request_multiple( array $requests, array $options ): array
ParameterTypeDescription
$requestsarrayArray of request data arrays (url, headers, data, options)
$optionsarrayGlobal options

Returns: array — Array of Response objects (may contain Exception or string values).

test()

Self-test whether the transport can be used.

php
public static function test( array $capabilities = [] ): bool
ParameterTypeDescription
$capabilitiesarray<string, bool>Capabilities to test (e.g., ['ssl' => true])

Returns: bool — Whether the transport is available.

Implementations

  • WpOrgRequestsTransportCurl — cURL transport
  • WpOrgRequestsTransportFsockopen — fsockopen transport