wp-includes/ai-client/adapters/class-wp-ai-client-http-client.php:29PSR-18 HTTP Client adapter using WordPress HTTP API.
$response_factoryprivate$stream_factoryprivateclass WP_AI_Client_HTTP_Client implements ClientInterface, ClientWithOptionsInterface { /** * Response factory instance. * * @since 7.0.0 */ private ResponseFactoryInterface $response_factory; /** * Stream factory instance. * * @since 7.0.0 */ private StreamFactoryInterface $stream_factory; /** * Constructor. * * @since 7.0.0 * * @param ResponseFactoryInterface $response_factory PSR-17 Response factory. * @param StreamFactoryInterface $stream_factory PSR-17 Stream factory. */ public function __construct( ResponseFactoryInterface $response_factory, StreamFactoryInterface $stream_factory ) { $this->response_factory = $response_factory; $this->stream_factory = $stream_factory; } /** * Sends a PSR-7 request and returns a PSR-7 response. * * @since 7.0.0 * * @param RequestInterface $request The PSR-7 request. * @return ResponseInterface The PSR-7 response. * * @throws NetworkException If the WordPress HTTP request fails. */ public function sendRequest( RequestInterface $request ): ResponseInterface { $args = $this->prepare_wp_args( $request ); $url = (string) $request->getUri(); $response = wp_safe_remote_request( $url, $args ); if ( is_wp_error( $response ) ) { $message = sprintf( /* translators: 1: HTTP method (e.g. GET, POST). 2: Request URL. 3: Error message. */ __( 'Network error occurred while sending %1$s request to %2$s: %3$s' ), $request->getMethod(), $url, $response->get_error_message() ); throw new NetworkException( $message ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped } return $this->create_psr_response( $response ); } /** * Sends a PSR-7 request with transport options and returns a PSR-7 response. * * @since 7.0.0 * * @param RequestInterface $request The PSR-7 request. * @param RequestOptions $options Transport options for the request. * @return ResponseInterface The PSR-7 response. * * @throws NetworkException If the WordPress HTTP request fails. */ public function sendRequestWithOptions( RequestInterface $request, RequestOptions $options ): ResponseInterface { $args = $this->prepare_wp_args( $request, $options ); $url = (string) $request->getUri(); $response = wp_safe_remote_request( $url, $args ); if ( is_wp_error( $response ) ) { $message = sprintf( /* translators: 1: HTTP method (e.g. GET, POST). 2: Request URL. 3: Error message. */ __( 'Network error occurred while sending %1$s request to %2$s: %3$s' ),Introduced in 7.0.0. Unchanged from 7.0.4 through 7.1.0.
Signature, return type and hooks compared across 2 parsed releases.
src/wp-includes/ai-client/adapters/class-wp-ai-client-http-client.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.