From 4fd10f1e7b3cd50df8a30d327d6052461487f616 Mon Sep 17 00:00:00 2001 From: Maja Pawlina Date: Sat, 8 Jun 2024 18:40:44 +0200 Subject: [PATCH 1/2] Temporary change protocol HTTP/1.1 -> HTTP/1.0, remove excessive line-ending's replacement, add null check for 'content-length' header (#104) --- src/WordPress/AsyncHttp/Client.php | 2 +- src/WordPress/AsyncHttp/async_http_streams.php | 4 ++-- 2 files changed, 3 insertions(+), 3 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..cc3a4630 100644 --- a/src/WordPress/AsyncHttp/async_http_streams.php +++ b/src/WordPress/AsyncHttp/async_http_streams.php @@ -220,7 +220,7 @@ function stream_http_prepare_request_bytes( $url ) { $host = $parts['host']; $path = $parts['path'] . ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' ); $request = << Date: Sat, 15 Jun 2024 15:38:04 +0200 Subject: [PATCH 2/2] Use standardised line-ending \r\n, regardless of underlying system --- .../AsyncHttp/async_http_streams.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/WordPress/AsyncHttp/async_http_streams.php b/src/WordPress/AsyncHttp/async_http_streams.php index cc3a4630..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 = <<