Hi there.

I was wondering why I was not able to get cURL use Digest Authentification. The
reason is the following:

In ext/curl/interface.c, there is (lines 834-836) :

----
#ifdef CURLOPT_HTTPAUTH /* only in curl 7.10.6 */
                case CURLOPT_HTTPAUTH:
#endif
----

However, CURLOPT_HTTAUTH can't be tested that way since it's inside a enum. See
curl.h, line 314 (in curl.h from curl-7.11.0 for instance):

----
typedef enum {
  CINIT(NOTHING, LONG, 0), /********* the first one is unused ************/
----
... etc .. until you have :
----
  /* Set this to a bitmask value to enable the particular authentications
     methods you like. Use this in combination with CURLOPT_USERPWD.
     Note that setting multiple bits may cause extra network round-trips. */
  CINIT(HTTPAUTH, LONG, 107),
----

So, if ever one wants to keep conditional compilation for this option, one
can use this ugly mess instead :-) :

---
#define CURL_HAS_HTTPAUTH

#if LIBCURL_VERSION_MAJOR <= 7
#if LIBCURL_VERSION_MAJOR < 7
#undef CURL_HAS_HTTPAUTH
#else
#if LIBCURL_VERSION_MINOR < 10
#undef CURL_HAS_HTTPAUTH
#else
#if LIBCURL_VERSION_MINOR == 10
#if LIBCURL_VERSION_PATCH < 6
#undef CURL_HAS_HTTPAUTH
#endif // LIBCURL_VERSION_PATCH < 6
#endif // LIBCURL_VERSION_MINOR == 10
#endif // LIBCURL_VERSION_MINOR < 10
#endif // LIBCURL_VERSION_MAJOR < 7
#endif // LIBCURL_VERSION_MAJOR <= 7
---

and then use, in interface.c, lines 834-836:

----
#ifdef CURLOPT_HAS_HTTPAUTH /* only in curl 7.10.6 */
                case CURLOPT_HTTPAUTH:
#endif
----

However won't it be simpler to suppose that, with PHP5, cURL must be at least 7.11.0 
and drop all that
tests?

Now, to end that matter, I would have spared hours if, still in interface.c, I would 
have found, starting
line 1089:

---
        default:
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option"); 
                RETURN_FALSE;
---

Cheers,

        Bernard

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to