PHP cURL: Max Length on CURLOPT_USERPWD?

社会主义新天地 提交于 2019-12-07 10:21:47

问题


I have a simple GET request in PHP using cURL. It is using basic auth for authentication.

However when the {username}:{password} is longer than 266 characters, it appears to be getting truncated. I looked everywhere but haven't found any documentation stating this. Is it just me?

$data = curl_init($url);

curl_setopt($data, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($data, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

$results = curl_exec($data);

echo $results;

curl_close($data);

回答1:


I'm not a C expert but I found the following code in the CURL source (!NOT the php extension but the original curl) Looks like CURL only allocates 256byte for the password.

EDIT Removed the old code, because as Daniel Steinberg stated below this code is not used anymore.



来源:https://stackoverflow.com/questions/13617278/php-curl-max-length-on-curlopt-userpwd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!