Skip to content
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

Add missing CURLOPT constants #3636

Merged
merged 4 commits into from
Sep 29, 2024
Merged

Conversation

haszi
Copy link
Contributor

@haszi haszi commented Aug 1, 2024

Add the 52 missing CURLOPT_* constants and their descriptions to the cURL predefined constant list.

Reference used: https://curl.se/libcurl/c/symbols-in-versions.html

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Cursory glance, main question is if the extension handles boolean options with a bool or not.

Also I don't remember if @cmb69 knows a lot about cURL or not.

reference/curl/constants_curl_setopt.xml Outdated Show resolved Hide resolved
reference/curl/constants_curl_setopt.xml Outdated Show resolved Hide resolved
reference/curl/constants_curl_setopt.xml Outdated Show resolved Hide resolved
reference/curl/constants_curl_setopt.xml Outdated Show resolved Hide resolved
reference/curl/constants_curl_setopt.xml Outdated Show resolved Hide resolved
reference/curl/constants_curl_setopt.xml Outdated Show resolved Hide resolved
Comment on lines 1211 to 1254
If set to <literal>0</literal>, transfer decoding is disabled.
If set to <literal>1</literal>, transfer decoding is enabled (default).
Copy link
Member

Choose a reason for hiding this comment

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

Does this check for a boolean value in the extension or just doesn't care?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The extension just doesn't care and converts all int and bool options' values to long internally.

Copy link
Member

Choose a reason for hiding this comment

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

CURLOPT_HTTP_TRANSFER_DECODING;:

Pass a long to tell libcurl how to act on transfer decoding. If set to zero, transfer decoding is disabled, if set to 1 it is enabled (default).

I wonder how that is actually implemented in cURL.

@haszi
Copy link
Contributor Author

haszi commented Aug 31, 2024

Cursory glance, main question is if the extension handles boolean options with a bool or not.

If I understand the source correctly, the extension converts all values to long before passing them to the appropriate C function. I tested it locally and bool CURLOPT options accepted bool, int and float values too.

@haszi haszi force-pushed the Add-missing-CURLOPT-constants branch from bc3f0e2 to 001cfa5 Compare September 1, 2024 12:13
@haszi
Copy link
Contributor Author

haszi commented Sep 1, 2024

@Girgias I've made some updates to the constant list based on your review comments. Could you check my last commit and let me know whether the general direction of the changes will work or not? If it does, I'll update the entire file. If it doesn't, I didn't waste too much time on it yet. :-)

@haszi haszi requested a review from Girgias September 1, 2024 12:17
@Girgias
Copy link
Member

Girgias commented Sep 11, 2024

@Girgias I've made some updates to the constant list based on your review comments. Could you check my last commit and let me know whether the general direction of the changes will work or not? If it does, I'll update the entire file. If it doesn't, I didn't waste too much time on it yet. :-)

I quite like what you did in the last commit :)

@haszi
Copy link
Contributor Author

haszi commented Sep 14, 2024

A note in case someone would like to tackle this in php-src: values passed to some of the CURLOPT_* constants are not type checked and these constants should probably be added to the appropriate parts of the huge switch statement of _php_curl_setopt() in ext/curl's interface.c.

The constants (so far):
CURLOPT_ENCODING
CURLOPT_FNMATCH_FUNCTION
CURLOPT_FTPAPPEND
CURLOPT_FTPLISTONLY
CURLOPT_FTP_RESPONSE_TIMEOUT
CURLOPT_FTP_SSL
CURLOPT_HEADERFUNCTION
CURLOPT_KEYPASSWD
CURLOPT_KRB4LEVEL
CURLOPT_MAIL_RCPT_ALLOWFAILS (replaces mistyped CURLOPT_MAIL_RCPT_ALLLOWFAILS)
CURLOPT_READDATA (replaces CURLOPT_INFILE)
CURLOPT_READFUNCTION

@cmb69
Copy link
Member

cmb69 commented Sep 15, 2024

CURLOPT_FNMATCH_FUNCTION and CURLOPT_HEADERFUNCTION are already properly handled there (see the "callables" section at the top of that switch (macro magic). The others are aliases for already handled cases, and there must be no duplicates (adding a comment might make sense, though).

It would be more important, I think, to declare the missing @aliases in curl.stub.php.

@haszi
Copy link
Contributor Author

haszi commented Sep 15, 2024

CURLOPT_FNMATCH_FUNCTION and CURLOPT_HEADERFUNCTION are already properly handled there (see the "callables" section at the top of that switch (macro magic).

@cmb69 Sorry that I wasn't specific enough but I meant that these constants are not being type checked on master anymore (php/php-src#13291 removed the two you have mentioned). But you're right, these were there before php/php-src#13291 so I'm really suggesting to take a look at these on master only.

@cmb69
Copy link
Member

cmb69 commented Sep 15, 2024

@haszi, I've actually debugged CURLOPT_FNMATCH_FUNCTION and CURLOPT_HEADERFUNCTION on master, and both are properly type checked. As of php/php-src#13291, this happens due to HANDLE_CURL_OPTION_CALLABLE(ch, CURLOPT_FNMATCH_, handlers.fnmatch, curl_fnmatch); and HANDLE_CURL_OPTION_CALLABLE_PHP_CURL_USER(ch, CURLOPT_HEADER, write_header);. You just won't be able to seek for these constants, due to the macro magic.

@haszi
Copy link
Contributor Author

haszi commented Sep 15, 2024

@haszi, I've actually debugged CURLOPT_FNMATCH_FUNCTION and CURLOPT_HEADERFUNCTION on master, and both are properly type checked. As of php/php-src#13291, this happens due to HANDLE_CURL_OPTION_CALLABLE(ch, CURLOPT_FNMATCH_, handlers.fnmatch, curl_fnmatch); and HANDLE_CURL_OPTION_CALLABLE_PHP_CURL_USER(ch, CURLOPT_HEADER, write_header);. You just won't be able to seek for these constants, due to the macro magic.

You're right. How did I even miss that part? Sorry for the noise and thanks for checking on this. :-)

@haszi haszi force-pushed the Add-missing-CURLOPT-constants branch from 001cfa5 to 06010a6 Compare September 24, 2024 21:49
@haszi
Copy link
Contributor Author

haszi commented Sep 24, 2024

@Girgias I've added some applicable tags, information on what type of value each option accepts and (where known) what the default value is.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Not sure if the acronym tag comments are that useful as it would be adding a lot of them

</term>
<listitem>
<para>
Setting this option to <literal>1</literal> will cause FTP uploads
Copy link
Member

Choose a reason for hiding this comment

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

I think having an <acronym> tag around FTP would be good here.

reference/curl/constants_curl_setopt.xml Outdated Show resolved Hide resolved
based on the protocol it is used with.
FTP and SFTP based URLs will list only the names of files in a directory.
POP3 will list the email message or messages on the POP3 server.
For FILE, this option has no effect
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what

For FILE [...]

refers to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically file://.

Comment on lines +443 to +444
FTP and SFTP based URLs will list only the names of files in a directory.
POP3 will list the email message or messages on the POP3 server.
Copy link
Member

Choose a reason for hiding this comment

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

FTP and POP3 have acronyms defined but not SFTP

</term>
<listitem>
<para>
Pass a <type>string</type> that will be sent as account information over FTP
Copy link
Member

Choose a reason for hiding this comment

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

Acronym tag for FTP

Comment on lines +950 to +951
This option makes cURL use CCC (Clear Command Channel)
which shuts down the SSL/TLS layer after authenticating
Copy link
Member

Choose a reason for hiding this comment

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

Possibly add CCC to the acronyms file and refer to it here?

<para>
Set to <literal>1</literal> to send a <literal>PRET</literal> command
before <literal>PASV</literal> (and <literal>EPSV</literal>).
Has no effect when using the active FTP transfers mode.
Copy link
Member

Choose a reason for hiding this comment

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

Acronym tag for FTP

</term>
<listitem>
<para>
If set to a <type>string</type> naming a file holding a CA certificate in PEM format,
Copy link
Member

Choose a reason for hiding this comment

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

Acronym tag around PEM

effectively disabling the proxy.
Setting this option to an empty <type>string</type> enables the proxy for all hostnames.
Since cURL 7.86.0, IP addresses set with this option
can be provided using CIDR notation.
Copy link
Member

Choose a reason for hiding this comment

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

CIDR maybe should have an acronym defined

reference/curl/constants_curl_setopt.xml Outdated Show resolved Hide resolved
@cmb69
Copy link
Member

cmb69 commented Sep 27, 2024

Not sure if the acronym tag comments are that useful as it would be adding a lot of them

At least adding some would be great! And others might be added later; in my opinion, our current list of acronyms is really meager.

@haszi
Copy link
Contributor Author

haszi commented Sep 28, 2024

Not sure if the acronym tag comments are that useful as it would be adding a lot of them

At least adding some would be great! And others might be added later; in my opinion, our current list of acronyms is really meager.

I took a look at acronyms.xml in doc-base and we only have 70 acronyms listed there. While I agree that more need to be added there and used on the CURLOPT_* constants page, I think I'd like to tackle that as a separate set of PRs (ie. adding them in doc-base and probably a large number of PRs adding the <acronym> tags for a large part of the doc-en files).

Another (selfish) reason is that I have a PR ready with the same type of tags/value type/default value changes made to all CURLOPT_* constants that I've added to ones in this PR and that PR is already humongous. :-)

@haszi haszi requested review from cmb69 and Girgias September 28, 2024 14:11
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

On a cursory look, this looks good to me (a single nit below). And I'm fine with postponing the acronyms.

Maybe wait on @Girgias's review before merging.

<member><literal>confidential</literal></member>
<member><literal>private</literal></member>
</simplelist>
.
Copy link
Member

Choose a reason for hiding this comment

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

I guess that stray period looks strange when rendered; I'd probably remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The period is needed at the end of the sentence because <simplelist> rendering only adds the <member> separating commas.
That <simplelist> actually renders like this:

This should be set to one of the following strings: clear, safe, confidential, private .

Copy link
Member

Choose a reason for hiding this comment

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

D'oh! I've missed the type="inline". Sorry for the noise!

@haszi
Copy link
Contributor Author

haszi commented Sep 28, 2024

One more thing in regards to acronyms: we should probably add an ENTITY for at least the most frequently used ones (eg.: HTTP, FTP, SSL/TLS, etc.) so that we can use something like &HTTP; instead of the unnecessarily long <acronym>HTTP</acronym>.

@Girgias
Copy link
Member

Girgias commented Sep 29, 2024

One more thing in regards to acronyms: we should probably add an ENTITY for at least the most frequently used ones (eg.: HTTP, FTP, SSL/TLS, etc.) so that we can use something like &HTTP; instead of the unnecessarily long <acronym>HTTP</acronym>.

That is a good point, could added in doc-base/entities/global.ent

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

LGTM :)

@Girgias Girgias merged commit 5af4624 into php:master Sep 29, 2024
2 checks passed
@haszi haszi deleted the Add-missing-CURLOPT-constants branch September 29, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants