From 239f43e4e46834c77e761779bd332e8644e47d2d Mon Sep 17 00:00:00 2001 From: Maja Pawlina Date: Sun, 16 Jun 2024 00:53:43 +0200 Subject: [PATCH] Fix issues in HTTP client (#106) --- src/WordPress/AsyncHttp/Client.php | 2 +- .../AsyncHttp/async_http_streams.php | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/WordPress/AsyncHttp/Client.php b/src/WordPress/AsyncHttp/Client.php index dd3dec0c..8763c835 100644 --- a/src/WordPress/AsyncHttp/Client.php +++ b/src/WordPress/AsyncHttp/Client.php @@ -192,7 +192,7 @@ public function process_queue() { foreach ( $streams as $k => $stream ) { $request = $enqueued[ $k ]; - $total = $response_headers[ $k ]['headers']['content-length']; + $total = $response_headers[ $k ]['headers']['content-length'] ?? null; $this->requests[ $request ]->state = RequestInfo::STATE_STREAMING; $this->requests[ $request ]->stream = stream_monitor_progress( $stream, diff --git a/src/WordPress/AsyncHttp/async_http_streams.php b/src/WordPress/AsyncHttp/async_http_streams.php index 71d4581b..24a63839 100644 --- a/src/WordPress/AsyncHttp/async_http_streams.php +++ b/src/WordPress/AsyncHttp/async_http_streams.php @@ -219,18 +219,17 @@ function stream_http_prepare_request_bytes( $url ) { $parts = parse_url( $url ); $host = $parts['host']; $path = $parts['path'] . ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' ); - $request = <<