From e13a898a543bd0774e06731aa1927d76b6617cc5 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Tue, 7 Jan 2020 11:57:56 +0800 Subject: [PATCH] add clear --- common/HttpClient.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/HttpClient.php b/common/HttpClient.php index 39d28f5..0411b4c 100644 --- a/common/HttpClient.php +++ b/common/HttpClient.php @@ -428,15 +428,18 @@ class HttpClient curl_close($ch); if ($output === FALSE) { - return new Result(['code' => 500, 'message' => curl_error($ch)]); - } + $data = new Result(['code' => 500, 'message' => curl_error($ch)]); + } else { + [$header, $body, $status] = $this->explode($output); - [$header, $body, $status] = $this->explode($output); - - if ($status != 200) { - return new Result(['code' => 500, 'message' => $body, 'header' => $header]); + if ($status != 200) { + $data = new Result(['code' => 500, 'message' => $body, 'header' => $header]); + } else { + $data = $this->structure($body, $data, $header); + } } - return $this->structure($body, $data, $header); + unset($ch); + return $data; } catch (\Exception $exception) { return new Result(['code' => 500, 'message' => $exception->getMessage(), 'header' => []]); }