|
@@ -125,15 +125,13 @@ class Webservice
|
|
|
{
|
|
|
try {
|
|
|
$headers = array();
|
|
|
- if ($token = $this->securityTokenStorage->getToken()) {
|
|
|
- if (method_exists($token, 'getAccessToken')) {
|
|
|
- $headers[] = 'Authorization: Bearer ' . $token->getAccessToken();
|
|
|
- }
|
|
|
+ $token = $this->securityTokenStorage->getToken();
|
|
|
+ if ($token && method_exists($token, 'getAccessToken')) {
|
|
|
+ $headers[] = 'Authorization: Bearer ' . $token->getAccessToken();
|
|
|
} elseif (!empty($credentials) && isset($credentials['username']) && isset($credentials['password'])) {
|
|
|
$headers[] = 'Authorization: Basic ' . base64_encode($credentials['username'] . ":" . $credentials['password']);
|
|
|
- } else {
|
|
|
- return '';
|
|
|
}
|
|
|
+
|
|
|
$request = new HttpRequest($method, $url);
|
|
|
if (!empty($data)) {
|
|
|
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
|
|
@@ -144,7 +142,7 @@ class Webservice
|
|
|
$this->httpClient->send($request, $response);
|
|
|
$response = $response->getContent();
|
|
|
} catch (RequestException $ex) {
|
|
|
- $response = '';
|
|
|
+ throw $ex;
|
|
|
}
|
|
|
|
|
|
return $response;
|