Jump to content

The cURL "features" Bitfield


iwato

Recommended Posts

Question: What happens when a bit-wise comparison of the cURL features' property does match the value of its own corresponding constants? Should I be concerned?Background: While exploring the utility of the curl_version() function I ran across a way to perform a bit-wise comparison of the "features" property of my current version of cURL with the values of several corresponding cURL constants. What I discovered is a mismatch. This mismatch appears unusual, insofar as the constants and the features appear to come with the same extension.

<?php	$version = curl_version();	$bitfields = Array(				'CURL_VERSION_IPV6', 				'CURL_VERSION_KERBEROS4', 				'CURL_VERSION_SSL', 				'CURL_VERSION_LIBZ'				);	foreach($bitfields as $feature) {		echo $feature . ($version['features'] & constant($feature) ? ' matches' : ' does not match'); echo '<br />';		echo PHP_EOL;	}?>

Roddy

Link to comment
Share on other sites

It would help to show the output of that, but if they don't match that just means those features aren't supported on your system. $version['features'] is a bitmask which contains all supported features, and that code compares each constant with the bitmask to see if the particular feature is supported.

Link to comment
Share on other sites

It would help to show the output of that, but if they don't match that just means those features aren't supported on your system. $version['features'] is a bitmask which contains all supported features, and that code compares each constant with the bitmask to see if the particular feature is supported.
Please find below the requested output.CURL_VERSION_IPV6 matchesCURL_VERSION_KERBEROS4 does not matchCURL_VERSION_SSL matchesCURL_VERSION_LIBZ matchesAlso, please respond to the comment "This mismatch appears unusual, insofar as the constants and the features appear to come with the same extension."Roddy
Link to comment
Share on other sites

Those constants are only going to be defined if the features they represent are supported. Instead of "matches" and "does not match", it may make more sense if you use "supported" and "not supported". That output is telling you that the IPV6 option is supported on your server, the Kerberos option is not, and the SSL and libz options are supported. The code is just comparing each individual option to the list of all supported options to figure out which options are supported on the server.

Link to comment
Share on other sites

Those constants are only going to be defined if the features they represent are supported.
So, if I have understood you correctly, the bitmask returned as the value of $version['features'] corresponds to my OS configuration irrespective of the PHP cURL extension, and the constants CURL_VERSION_IPV6, CURL_VERSION_KERBEROS4, CURL_VERSION_SSL, and CURL_VERSION_LIBZ correspond only to the settings of my cURL extension. Is this correct?This said, may I not then also conclude with good confidence that the MacOS 10.5.8 does not support KEREBEROS4?Roddy
Link to comment
Share on other sites

I don't know if cURL simply looks at the environment to decide what is supported or if it is compiled with support for certain options. Regardless, the bit mask of supported options only indicates what your current implementation of cURL supports, nothing more and nothing less. Mac OS does have support for Kerberos from what I can tell.

Link to comment
Share on other sites

I don't know if cURL simply looks at the environment to decide what is supported or if it is compiled with support for certain options. Regardless, the bit mask of supported options only indicates what your current implementation of cURL supports, nothing more and nothing less.
Thank you for your valuable opinion.
Mac OS does have support for Kerberos from what I can tell.
The conclusion did appear whacky, didn't it?Roddy
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...