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
setopt: use the handler table for protocol name to number conversions #9472
Conversation
@bagder: it seems not recognizing disabled protocols is a big problem for the cli tool and the tests.
|
Hm, I think maybe the first alternative is the best: Accept this restriction and adapt tests & cli tool to it I believe I intended for But if we don't work that way, we also can't detect typos... |
OK, I will change that way. It will probably require several checks and take some time. Turning this PR into a draft now. |
975b89c
to
13290a0
Compare
ff7bb63
to
c9298ae
Compare
@bagder: with this PR, the cli tool relies on the protocols listed by |
I'm not super happy about that, as they will then end up in the We could possibly add something special for the curl tool that just doesn't show all of them. |
I understand your dilemma. In all cases, the tool should adapt. I'll look at it. Thanks for your reply. |
I've added "warts" code snippets to the cli tool to support the library whether it returns RTMP?* protocols or not. Those protocols are NOT returned yet. |
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 think this looks very good. Just some minor comments/questions.
tests/data/test1401
Outdated
@@ -91,7 +91,7 @@ int main(int argc, char *argv[]) | |||
curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L); | |||
%endif | |||
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); | |||
curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "http,ftp,file"); | |||
curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "http"); |
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.
This is the only test case verifying CURLOPT_PROTOCOLS_STR
with ---libcurl
, shouldn't it use more than one protocol ?
We can just make the test require support for those protocols to be present.
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.
Yes, but how to check for 3 protocols in the same test? I didn't find a way to make the program "auto-adaptive" and still match the <verify>
data.
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.
In the <client>
section you list all features that are required:
<features>
http
ftp
file
</features>
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.
Thanks for the hint. I didn't know protocol names were features !
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.
Fixed now!
This also returns error CURLE_UNSUPPORTED_PROTOCOL rather than CURLE_BAD_FUNCTION_ARGUMENT when a listed protocol name is not found. A new schemelen parameter is added to Curl_builtin_scheme() to support this extended use. Note that disabled protocols are not recognized anymore. Tests adapted accordingly.
As they are now rejected by the library, take care of not passing disabled protocol names to CURLOPT_PROTOCOLS_STR and CURLOPT_REDIR_PROTOCOLS_STR. Rather than using the CURLPROTO_* constants, dynamically assign protocol numbers based on the order they are listed by curl_version_info(). New type proto_set_t implements prototype bit masks: it should therefore be large enough to accomodate all library-enabled protocols. If not, protocol numbers beyond the bit count of proto_set_t are recognized but "inaccessible": when used, a warning is displayed and the value is ignored. Should proto_set_t overflows, enabled protocols are reordered to force those having a public CURLPROTO_* representation to be accessible. Code has been added to subordinate RTMP?* protocols to the presence of RTMP in the enabled protocol list, being returned by curl_version_info() or not.
Disabled protocols are now handled as if they were unknown. Also update the possible protocol list.
Thanks! |
Thanks for your help. |
This also returns error
CURLE_UNSUPPORTED_PROTOCOL
rather thanCURLE_BAD_FUNCTION_ARGUMENT
when a listed protocol name is not found.A new
schemelen
parameter is added toCurl_builtin_scheme()
to support this extended use.Note that disabled protocols are not recognized anymore.
Test programs 1597 and 1911 adapted accordingly.