Skip to content

Commit 1b14777

Browse files
bug #59654 [HttpClient] Fix uploading files > 2GB (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- [HttpClient] Fix uploading files > 2GB | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT See: - https://curl.se/libcurl/c/CURLOPT_INFILESIZE.html - https://github.com/curl/curl/blob/b13e9066b3dfd65ba8aadc336232ae7832ac687a/include/curl/curl.h#L1541 - https://www.php.net/manual/en/curl.constants.php#constant.curlopt-infile Commits ------- dc71298 [HttpClient] Fix uploading files > 2GB
2 parents 819e3e8 + dc71298 commit 1b14777

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function request(string $method, string $url, array $options = []): Respo
237237

238238
if (!\is_string($body)) {
239239
if (\is_resource($body)) {
240-
$curlopts[\CURLOPT_INFILE] = $body;
240+
$curlopts[\CURLOPT_READDATA] = $body;
241241
} else {
242242
$curlopts[\CURLOPT_READFUNCTION] = static function ($ch, $fd, $length) use ($body) {
243243
static $eof = false;
@@ -316,6 +316,9 @@ public function request(string $method, string $url, array $options = []): Respo
316316
}
317317

318318
foreach ($curlopts as $opt => $value) {
319+
if (\CURLOPT_INFILESIZE === $opt && $value >= 1 << 31) {
320+
$opt = 115; // 115 === CURLOPT_INFILESIZE_LARGE, but it's not defined in PHP
321+
}
319322
if (null !== $value && !curl_setopt($ch, $opt, $value) && \CURLOPT_CERTINFO !== $opt && (!\defined('CURLOPT_HEADEROPT') || \CURLOPT_HEADEROPT !== $opt)) {
320323
$constantName = $this->findConstantName($opt);
321324
throw new TransportException(sprintf('Curl option "%s" is not supported.', $constantName ?? $opt));
@@ -472,7 +475,7 @@ private function validateExtraCurlOptions(array $options): void
472475
\CURLOPT_RESOLVE => 'resolve',
473476
\CURLOPT_NOSIGNAL => 'timeout',
474477
\CURLOPT_HTTPHEADER => 'headers',
475-
\CURLOPT_INFILE => 'body',
478+
\CURLOPT_READDATA => 'body',
476479
\CURLOPT_READFUNCTION => 'body',
477480
\CURLOPT_INFILESIZE => 'body',
478481
\CURLOPT_POSTFIELDS => 'body',

0 commit comments

Comments
 (0)