summaryrefslogtreecommitdiff
path: root/app/Core/Http/Client.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2018-03-02 13:41:37 -0800
committerFrédéric Guillot <fred@kanboard.net>2018-03-02 13:41:37 -0800
commitf92eb448cbee45640351c28855045d55ac258590 (patch)
tree670a345f30b36914030db8b3a36523dca55bf33b /app/Core/Http/Client.php
parentebe04e672c7982a1560133ee87f417560a851a10 (diff)
Add response body to InvalidStatusException
Diffstat (limited to 'app/Core/Http/Client.php')
-rw-r--r--app/Core/Http/Client.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/app/Core/Http/Client.php b/app/Core/Http/Client.php
index de7c6ec6..3793fa33 100644
--- a/app/Core/Http/Client.php
+++ b/app/Core/Http/Client.php
@@ -164,7 +164,6 @@ class Client extends Base
$startTime = microtime(true);
$stream = @fopen(trim($url), 'r', false, stream_context_create($this->getContext($method, $content, $headers, $raiseForErrors)));
- $response = '';
if (! is_resource($stream)) {
$this->logger->error('HttpClient: request failed ('.$url.')');
@@ -176,14 +175,14 @@ class Client extends Base
return '';
}
- $response = stream_get_contents($stream);
+ $body = stream_get_contents($stream);
$metadata = stream_get_meta_data($stream);
if ($raiseForErrors && array_key_exists('wrapper_data', $metadata)) {
$statusCode = $this->getStatusCode($metadata['wrapper_data']);
if ($statusCode >= 400) {
- throw new InvalidStatusException('Request failed with status code '.$statusCode, $statusCode);
+ throw new InvalidStatusException('Request failed with status code '.$statusCode, $statusCode, $body);
}
}
@@ -192,11 +191,11 @@ class Client extends Base
$this->logger->debug('HttpClient: headers='.var_export($headers, true));
$this->logger->debug('HttpClient: payload='.$content);
$this->logger->debug('HttpClient: metadata='.var_export($metadata, true));
- $this->logger->debug('HttpClient: response='.$response);
+ $this->logger->debug('HttpClient: body='.$body);
$this->logger->debug('HttpClient: executionTime='.(microtime(true) - $startTime));
}
- return $response;
+ return $body;
}
/**