From 535dbda6b48171f8115b455e54790de94d97d42a Mon Sep 17 00:00:00 2001 From: Murilo Ijanc Date: Sun, 26 Jul 2026 16:41:48 -0300 Subject: Initial import --- includes/class-cepis-woo-transport.php | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 includes/class-cepis-woo-transport.php (limited to 'includes/class-cepis-woo-transport.php') diff --git a/includes/class-cepis-woo-transport.php b/includes/class-cepis-woo-transport.php new file mode 100644 index 0000000..888be54 --- /dev/null +++ b/includes/class-cepis-woo-transport.php @@ -0,0 +1,58 @@ + $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 { + $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 ); + + return new Cepis\Response( + (int) wp_remote_retrieve_response_code( $response ), + is_object( $response_headers ) ? $response_headers->getAll() : (array) $response_headers, + (string) wp_remote_retrieve_body( $response ) + ); + } +} -- cgit v1.3