last_body; } /** * Perform a single GET. * * @param string $url Absolute URL, query string included. * @param array $headers Request headers as name => value. * @param float $timeout Seconds to allow for this attempt. * * @throws Cepis\NetworkException The request never completed. */ public function get( string $url, array $headers, float $timeout ): Cepis\Response { $this->last_body = ''; $response = wp_remote_get( $url, array( 'headers' => $headers, 'timeout' => $timeout, 'redirection' => 3, 'sslverify' => true, ) ); if ( is_wp_error( $response ) ) { throw new Cepis\NetworkException( esc_html( $response->get_error_message() ) ); } $response_headers = wp_remote_retrieve_headers( $response ); $this->last_body = (string) wp_remote_retrieve_body( $response ); return new Cepis\Response( (int) wp_remote_retrieve_response_code( $response ), is_object( $response_headers ) ? $response_headers->getAll() : (array) $response_headers, $this->last_body ); } }