mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #4331 from jeremyharris/master
Fix HttpSocket multiple auth requests
This commit is contained in:
commit
f6f794eb98
2 changed files with 24 additions and 2 deletions
|
@ -326,8 +326,11 @@ class HttpSocket extends CakeSocket {
|
|||
} 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;
|
||||
$authHeader = Hash::get($this->request, 'header.Authorization');
|
||||
if (empty($authHeader)) {
|
||||
$this->_setAuth();
|
||||
$this->request['auth'] = $this->_auth;
|
||||
}
|
||||
|
||||
if (is_array($this->request['body'])) {
|
||||
$this->request['body'] = http_build_query($this->request['body'], '', '&');
|
||||
|
|
|
@ -1074,6 +1074,16 @@ class HttpSocketTest extends CakeTestCase {
|
|||
));
|
||||
$this->assertEquals($this->Socket->request['auth'], array('Basic' => array('user' => 'joel', 'pass' => 'hunter2')));
|
||||
$this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic am9lbDpodW50ZXIy') !== false);
|
||||
|
||||
$this->Socket->configAuth('Basic', 'mark', 'password');
|
||||
$this->Socket->request(array(
|
||||
'method' => 'GET',
|
||||
'uri' => 'http://example.com/test',
|
||||
'header' => array(
|
||||
'Authorization' => 'OtherAuth Hi.There'
|
||||
)
|
||||
));
|
||||
$this->assertPattern('/Authorization: OtherAuth Hi\.There/m', $this->Socket->request['header']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1090,6 +1100,15 @@ class HttpSocketTest extends CakeTestCase {
|
|||
$this->Socket->get('/test2');
|
||||
$this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false);
|
||||
|
||||
$this->Socket->request(array(
|
||||
'method' => 'GET',
|
||||
'uri' => 'http://example.com/test',
|
||||
'header' => array(
|
||||
'Authorization' => 'OtherAuth Hi.There'
|
||||
)
|
||||
));
|
||||
$this->assertPattern('/Authorization: OtherAuth Hi\.There/m', $this->Socket->request['header']);
|
||||
|
||||
$this->Socket->get('/test3');
|
||||
$this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue