What does php's CURLOPT_USERPWD do

后端 未结 1 1718
你的背包
你的背包 2020-12-18 18:12

I was wondering what CURLOPT_USERPWD is actually doing to the url, header or data of a request. Is it INSTEAD OF the Authorization: Basic

相关标签:
1条回答
  • 2020-12-18 18:32

    Is it modifying the url to this?:

    username:password@someurl.com

    No, the url still the same. You can check with

    curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    

    This

    $encodedAuth = base64_encode(self::$pfAdapterUser.":".self::$pfAdapterPasswd);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Basic ".$encodedAuth));
    

    And this

    curl_setopt($ch, CURLOPT_USERPWD, self::$pfAdapterUser.":".self::$pfAdapterPasswd);
    

    are doing the same thing so there's no need to use them together (although it won't break), use one and it will work fine.

    0 讨论(0)
提交回复
热议问题