所以这就是我到目前为止所拥有的:
self::$connection = curl_init();
curl_setopt(self::$connection, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(self::$connection, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt(self::$connection, CURLOPT_URL, $url);
curl_exec(self::$connection); // Do a request that uses Basic Auth
curl_setopt(self::$connection, CURLOPT_HTTPAUTH, false); // <-- Not working as expected - I want to disable Basic Auth here
curl_setopt(self::$connection, CURLOPT_URL, $anotherURL);
curl_exec(self::$connection); // <-- Not working as expected - I want to do a request that does NOT use Basic Auth.
那么,如果我将 CURLOPT_HTTPAUTH 选项初始化为 CURLAUTH_BASIC,我将如何禁用它?
我需要使用相同的句柄(即 self::$connection)以获得持久的 HTTP 连接。