Skip to content

Commit 2074abf

Browse files
author
Ahmad Nassri
committed
keeping deprecated auth method functional
1 parent 96cdf61 commit 2074abf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Unirest/Request.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Request
1212
private static $socketTimeout = null;
1313
private static $defaultHeaders = array();
1414

15-
private static $auth => array (
15+
private static $auth = array (
1616
'user' => '',
1717
'pass' => '',
1818
'method' => CURLAUTH_BASIC
@@ -342,7 +342,14 @@ public static function send($method, $url, $body = null, $headers = array(), $us
342342
curl_setopt($ch, CURLOPT_TIMEOUT, self::$socketTimeout);
343343
}
344344

345-
if (!empty($self::auth['user'])) {
345+
// supporting deprecated http auth method
346+
if (!empty($username)) {
347+
curl_setopt($ch, CURLOPT_USERNAME, $username);
348+
curl_setopt($ch, CURLOPT_PASSWORD, $password);
349+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
350+
}
351+
352+
if (!empty(self::$auth['user'])) {
346353
curl_setopt($ch, CURLOPT_USERNAME, self::$auth['user']);
347354
curl_setopt($ch, CURLOPT_PASSWORD, self::$auth['pass']);
348355
curl_setopt($ch, CURLOPT_HTTPAUTH, self::$auth['method']);

0 commit comments

Comments
 (0)