From 5da9dac6aee40dabe4d1edd76c7e55f7d75c9938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 7 Oct 2021 15:10:27 +0200 Subject: [PATCH] Fix progress parameter type compatibility between cURL and StreamHandler (#2936) Unknown values of the progress called are filled with `0` by cURL and in fact the `CURLOPT_PROGRESSFUNCTION` parameters are explicitly typed `int` in CurlFactory. StreamHandler always provided `null` as the upload progress, because the progress is not known there. Adjust this to `0` for consistent behavior. --- src/Handler/StreamHandler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Handler/StreamHandler.php b/src/Handler/StreamHandler.php index c76b1c605..70c646be5 100644 --- a/src/Handler/StreamHandler.php +++ b/src/Handler/StreamHandler.php @@ -517,7 +517,9 @@ private function add_progress(RequestInterface $request, array &$options, $value $params, static function ($code, $a, $b, $c, $transferred, $total) use ($value) { if ($code == \STREAM_NOTIFY_PROGRESS) { - $value($total, $transferred, null, null); + // The upload progress cannot be determined. Use 0 for cURL compatibility: + // https://curl.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html + $value($total, $transferred, 0, 0); } } );