mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #1203 from cincodenada/patch_httpsocket
Add a bit of backwards compatibility for specifying auth in the config. Restore compatibility with older versions when providing auth data in the request data.
This commit is contained in:
commit
84c0de7e2d
2 changed files with 15 additions and 0 deletions
|
@ -323,6 +323,8 @@ class HttpSocket extends CakeSocket {
|
|||
|
||||
if (isset($this->request['uri']['user'], $this->request['uri']['pass'])) {
|
||||
$this->configAuth('Basic', $this->request['uri']['user'], $this->request['uri']['pass']);
|
||||
} elseif (isset($this->request['auth'], $this->request['auth']['method'], $this->request['auth']['user'], $this->request['auth']['pass'])) {
|
||||
$this->configAuth($this->request['auth']['method'], $this->request['auth']['user'], $this->request['auth']['pass']);
|
||||
}
|
||||
$this->_setAuth();
|
||||
$this->request['auth'] = $this->_auth;
|
||||
|
|
|
@ -1065,6 +1065,19 @@ class HttpSocketTest extends CakeTestCase {
|
|||
$socket->configAuth('Test', 'mark', 'passwd');
|
||||
$socket->get('http://example.com/test');
|
||||
$this->assertTrue(strpos($socket->request['header'], 'Authorization: Test mark.passwd') !== false);
|
||||
|
||||
$socket->configAuth(false);
|
||||
$socket->request(array(
|
||||
'method' => 'GET',
|
||||
'uri' => 'http://example.com/test',
|
||||
'auth' => array(
|
||||
'method'=>'Basic',
|
||||
'user' => 'joel',
|
||||
'pass' => 'hunter2'
|
||||
)
|
||||
));
|
||||
$this->assertEquals($socket->request['auth'],array('Basic' => array('user' => 'joel', 'pass' => 'hunter2')));
|
||||
$this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic am9lbDpodW50ZXIy') !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue