Skip to content

Commit

Permalink
Fix progress parameter type compatibility between cURL and StreamHand…
Browse files Browse the repository at this point in the history
…ler (#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.
  • Loading branch information
TimWolla committed Oct 7, 2021
1 parent 6b499cc commit 5da9dac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Handler/StreamHandler.php
Expand Up @@ -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);
}
}
);
Expand Down

0 comments on commit 5da9dac

Please sign in to comment.