Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5a7ad40bd | ||
|
|
8af870ff69 | ||
|
|
ae01978eb3 |
@@ -344,15 +344,13 @@ class Request
|
|||||||
|
|
||||||
// supporting deprecated http auth method
|
// supporting deprecated http auth method
|
||||||
if (!empty($username)) {
|
if (!empty($username)) {
|
||||||
curl_setopt($ch, CURLOPT_USERNAME, $username);
|
|
||||||
curl_setopt($ch, CURLOPT_PASSWORD, $password);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty(self::$auth['user'])) {
|
if (!empty(self::$auth['user'])) {
|
||||||
curl_setopt($ch, CURLOPT_USERNAME, self::$auth['user']);
|
|
||||||
curl_setopt($ch, CURLOPT_PASSWORD, self::$auth['pass']);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPAUTH, self::$auth['method']);
|
curl_setopt($ch, CURLOPT_HTTPAUTH, self::$auth['method']);
|
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, self::$auth['user'] . ':' . self::$auth['pass']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$proxy['address'] !== false) {
|
if (self::$proxy['address'] !== false) {
|
||||||
@@ -362,8 +360,7 @@ class Request
|
|||||||
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, self::$proxy['tunnel']);
|
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, self::$proxy['tunnel']);
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_PROXYAUTH, self::$proxy['auth']['method']);
|
curl_setopt($ch, CURLOPT_PROXYAUTH, self::$proxy['auth']['method']);
|
||||||
curl_setopt($ch, CURLOPT_PROXYUSERNAME, self::$proxy['auth']['user']);
|
curl_setopt($ch, CURLOPT_PROXYUSERPWD, self::$proxy['auth']['user'] . ':' . self::$proxy['auth']['pass']);
|
||||||
curl_setopt($ch, CURLOPT_PROXYPASSWORD, self::$proxy['auth']['pass']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
|||||||
@@ -71,13 +71,21 @@ class UnirestRequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(true, $args->gzipped);
|
$this->assertEquals(true, $args->gzipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicAuthentication()
|
public function testBasicAuthenticationDeprecated()
|
||||||
{
|
{
|
||||||
$response = Unirest\Request::get('http://httpbin.org/get', array(), array(), 'user', 'password');
|
$response = Unirest\Request::get('http://httpbin.org/get', array(), array(), 'user', 'password');
|
||||||
$headers = $response->body->headers;
|
$headers = $response->body->headers;
|
||||||
$this->assertEquals('Basic dXNlcjpwYXNzd29yZA==', $headers->Authorization);
|
$this->assertEquals('Basic dXNlcjpwYXNzd29yZA==', $headers->Authorization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBasicAuthentication()
|
||||||
|
{
|
||||||
|
Unirest\Request::auth('user', 'password');
|
||||||
|
$response = Unirest\Request::get('http://httpbin.org/get');
|
||||||
|
|
||||||
|
$this->assertEquals('Basic dXNlcjpwYXNzd29yZA==', $response->body->headers->Authorization);
|
||||||
|
}
|
||||||
|
|
||||||
public function testCustomHeaders()
|
public function testCustomHeaders()
|
||||||
{
|
{
|
||||||
$response = Unirest\Request::get('http://httpbin.org/get', array(
|
$response = Unirest\Request::get('http://httpbin.org/get', array(
|
||||||
|
|||||||
Reference in New Issue
Block a user