diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Core/Http/Client.php | 9 | ||||
-rw-r--r-- | app/Core/Http/InvalidStatusException.php | 9 |
2 files changed, 12 insertions, 6 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; } /** diff --git a/app/Core/Http/InvalidStatusException.php b/app/Core/Http/InvalidStatusException.php index 2d4a8d36..9834fe65 100644 --- a/app/Core/Http/InvalidStatusException.php +++ b/app/Core/Http/InvalidStatusException.php @@ -5,15 +5,22 @@ namespace Kanboard\Core\Http; class InvalidStatusException extends ClientException { protected $statusCode = 0; + protected $body = ''; - public function __construct($message, $statusCode) + public function __construct($message, $statusCode, $body) { parent::__construct($message); $this->statusCode = $statusCode; + $this->body = $body; } public function getStatusCode() { return $this->statusCode; } + + public function getBody() + { + return $this->body; + } } |