add clear

This commit is contained in:
as2252258@163.com
2020-01-07 11:57:56 +08:00
parent 40f73f7df8
commit e13a898a54
+10 -7
View File
@@ -428,15 +428,18 @@ class HttpClient
curl_close($ch); curl_close($ch);
if ($output === FALSE) { 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) {
$data = new Result(['code' => 500, 'message' => $body, 'header' => $header]);
if ($status != 200) { } else {
return new Result(['code' => 500, 'message' => $body, 'header' => $header]); $data = $this->structure($body, $data, $header);
}
} }
return $this->structure($body, $data, $header); unset($ch);
return $data;
} catch (\Exception $exception) { } catch (\Exception $exception) {
return new Result(['code' => 500, 'message' => $exception->getMessage(), 'header' => []]); return new Result(['code' => 500, 'message' => $exception->getMessage(), 'header' => []]);
} }