WP_AI_Client_HTTP_Client::prepare_wp_args
Prepares WordPress HTTP API arguments from a PSR-7 request.
Method of the class: WP_AI_Client_HTTP_Client{}
No Hooks.
Returns
Array
Usage
// private - for code of main (parent) class only $result = $this->prepare_wp_args( $request, ?RequestOptions $options ): array;
- $request(RequestInterface) (required)
- The PSR-7 request.
- ?RequestOptions $options
- .
Default:null
Changelog
| Since 7.0.0 | Introduced. |
WP_AI_Client_HTTP_Client::prepare_wp_args() WP AI Client HTTP Client::prepare wp args code WP 7.0
private function prepare_wp_args( RequestInterface $request, ?RequestOptions $options = null ): array {
$args = array(
'method' => $request->getMethod(),
'headers' => $this->prepare_headers( $request ),
'body' => $this->prepare_body( $request ),
'httpversion' => $request->getProtocolVersion(),
'blocking' => true,
);
if ( null !== $options ) {
if ( null !== $options->getTimeout() ) {
$args['timeout'] = $options->getTimeout();
}
if ( null !== $options->getMaxRedirects() ) {
$args['redirection'] = $options->getMaxRedirects();
}
}
return $args;
}