-
-
Notifications
You must be signed in to change notification settings - Fork 149
[PHP 8.1] Add CURLStringFile
polyfill
#334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If we add a test case (as you, I don't know which one exactly), it should with the native one and with the polyfilled one (when curl is not installed), so that we can prove that this is really a polyfill. |
Sounds like a plan. You can find an example of using the CLI webserver in tests here: |
Thanks a lot for the feedback. I totally forgot about the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please also add a line in the changelog? done for you
Thank you so much for the help @nicolas-grekas - I have made the changes. |
that's because your implementation relies on the fact that curl knows how to deal with a |
Thank you @stof. Looking at CURLFile doc, it says CURLFile should available in PHP >= 5.5. My direction is that the CLI server failed to start at all in older PHP versions. |
I tested with a PHP 7.3 setup, it indeed turns out that the problem is that CURLFile only supports streams in PHP >= 7.4, just like @stof mentioned. For PHP 7.0 through 7.3, I think we could get it working by temporarily writing the contents to a file, but I'm not sure if the effort is worth it. I will open the PR for review either way, and will happily work on support for older PHP versions if you think it's a worthwhile idea. 🤞🏼 Thank you. |
Can you please rebase? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I fixed my last comments)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just rebased and resolved @stof's comments.
Thank you @Ayesh. |
PHP 8.1 adds a new class
CURLStringFile
, that works similar toCURLFile
, but does not require a path to a file, and accepts a string of file contents instead. This can be polyfilled with aCURLFile
sub class that uses adata://
URI inside a constructure and callingCURLFile::__construct
with that data URI.Closes #333.
I will leave this as a draft because I'm not sure how to write tests for this. I'm thinking a PHP CLI server that echoes
$_FILES
, and a test that checks the returned content for file(s) that it uploaded.