PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTTP » HTTP_Request » Bug #1507

Basic auth in url is not honoured by default

Details

Submitted2004-05-26 13:22 UTC
Fromafradejas at mediafusion dot es
Assignedavb
StatusClosed
PackageHTTP_Request
PHP Version4.3.5
OSLinux
Roadmaps(Not assigned)

Comments

[2004-05-26 13:22 UTC] afradejas at mediafusion dot es

Description:
------------
Description:
Current HTTP_Request ignores any auth info present in the URI to request.
It's been discarded without notice.

package version: HTTP_Request
1.2.2 stable
but aplicable in older versions, too.

Proposed patch:
In function setURL(), right below the Net_URL instantation, add these 3 lines:

if ((!empty($this->_url->user)) || (!empty($this->_url->pass))) {
$this->setBasicAuth($request->_url->user,$request->_url->pass);
}

That should be enough.

Reproduce code:
---------------
script to reproduce the problem:

<?
include_once("HTTP/Request.php");
$url = "http://user:password@www.example.com/resource";
$request = &new HTTP_Request($url);
$request->sendRequest();
?>

The request goes out without the Authorization: header.

Expected result:
----------------
An

Authorization: Basic xxxxxxxxxxxxxxxxxx

should be present in the request sent.

[2004-05-26 17:02 UTC] afradejas at mediafusion dot es

Sorry, there was an error in my proposed patch:

if ((!empty($this->_url->user)) || (!empty($this->_url->pass))) {
$this->setBasicAuth($this->_url->user,$this->_url->pass);
}

Sorry for my quick copy&paste, I just took it from my local application sources.