|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51921 CURLOPT_USERPWD bogus when use without username
Submitted: 2010-05-26 13:51 UTC Modified: 2010-05-27 02:02 UTC
From: over at silversurfer7 dot de Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.2.13 OS: Debian 5.0 64bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
35 - 30 = ?
Subscribe to this entry?

 [2010-05-26 13:51 UTC] over at silversurfer7 dot de
When using CURLOPT_USERPWD within a cURL request u have to provide both username AND password to work properly.

I had a problem with accessing pages with Basicauth and NO username, just a Password.

curl then calculates the base64 wrong.

As workaround i have to calculate the base64 manually and provide it to curl via the headers option

Test script:
$curl = curl_init('http://localhost');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERPWD, ':password'); // no username
curl_setopt($curl, CURLOPT_VERBOSE, true);
$response = curl_exec($curl);

Expected result:
something like this in the request headers:

"Authorization: Basic OnRlc3Q="

Actual result:
"Authorization: Basic Og=="

(only the ":")


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-27 02:02 UTC]
-Status: Open +Status: Bogus
 [2010-05-27 02:02 UTC]
That would be an issue with libcurl then. PHP's curl extension just passes the options to libcurl.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jun 21 02:01:24 2021 UTC