Skip to content

ext/curl: set curl post size using CURLOPT_POSTFIELDSIZE_LARGE - #22842

Merged
devnexen merged 5 commits into
php:masterfrom
Sjord:curl-large-post
Aug 16, 2026
Merged

ext/curl: set curl post size using CURLOPT_POSTFIELDSIZE_LARGE#22842
devnexen merged 5 commits into
php:masterfrom
Sjord:curl-large-post

Conversation

@Sjord

@Sjord Sjord commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This is a 64-bit number on all platforms. This improves support of posting files larger than 2GB.

Comment thread ext/curl/interface.c Outdated
@Sjord
Sjord marked this pull request as ready for review July 21, 2026 15:14
@Sjord
Sjord requested a review from adoy as a code owner July 21, 2026 15:14
Comment thread ext/curl/interface.c
@Sjord

Sjord commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@Ayesh do you think it is worth it to create a test for this that posts >2GB?

@Sjord Sjord changed the title Set curl post size using CURLOPT_POSTFIELDSIZE_LARGE ext/curl: set curl post size using CURLOPT_POSTFIELDSIZE_LARGE Jul 30, 2026
@Girgias

Girgias commented Aug 7, 2026

Copy link
Copy Markdown
Member

I have created 2GB+ tests for ext/tidy, so yes I think it make sense to have one.

@Sjord

Sjord commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

I've added a test. It would be nice if it could also run on Windows (as that is the one platform that would profit from this), but the test currently relies on fork. I'll look into this some more later.

@Sjord

Sjord commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

I've changed the test for a simpler one that posts to caddy. It doesn't test the actual length of the posted content, but it tests the content-length header, which is an indication that curl received the correct length. It takes ~0.5 seconds, and takes ~2.5GB of memory.

@arnaud-lb arnaud-lb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me

@Sjord
Sjord requested a review from devnexen August 16, 2026 14:26
var_dump($response);

?>
--EXPECTF--

@devnexen devnexen Aug 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to bother with EXPECTF here since there is no format specifier.

@devnexen

Copy link
Copy Markdown
Member

also I think it is worth adding a NEWS entry ;)

Sjord added 5 commits August 16, 2026 17:52
The test (curl_post_large_string) posts data slightly bigger than fits
in a signed 32-bit number. It uses Caddy and not server.inc, because PHP
has limits on maximum upload size. It doesn't actually check whether it
uploads the correct number of bytes, but it does check the
Content-Length header, which is sufficient indication whether curl
understands the correct size.
devnexen
devnexen approved these changes Aug 16, 2026
@devnexen
devnexen merged commit 5e58399 into php:master Aug 16, 2026
18 checks passed
@devnexen

Copy link
Copy Markdown
Member

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants