HttpTransporter::convertFromPsr7Response( WordPressAiClientDependenciesPsrHttpMessageResponseInterface $psr7Response ): WordPressAiClientProvidersHttpDTOResponse

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Converts a PSR-7 response to a custom Response.

Parameters

$psr7ResponseWordPressAiClientDependenciesPsrHttpMessageResponseInterfacerequired
The PSR-7 response.

Return

WordPressAiClientProvidersHttpDTOResponse The custom response.

Source

private function convertFromPsr7Response(ResponseInterface $psr7Response): Response
{
    $body = (string) $psr7Response->getBody();
    // PSR-7 always returns headers as arrays, but HeadersCollection handles this
    return new Response(
        $psr7Response->getStatusCode(),
        $psr7Response->getHeaders(),
        // @phpstan-ignore-line
        $body === '' ? null : $body
    );
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.