add clear

This commit is contained in:
as2252258@163.com
2020-01-03 15:12:06 +08:00
parent f7863891c2
commit e435a3888b
+19 -6
View File
@@ -431,21 +431,34 @@ class HttpClient
return new Result(['code' => 500, 'message' => curl_error($ch)]);
}
[$header, $body] = explode("\r\n\r\n", $output);
$header = explode(PHP_EOL, $header);
$status = (int)explode(' ', trim($header[0]))[1];
$header = $this->headerFormat($header);
[$header, $body, $status] = $this->explode($output);
if ($status != 200) {
return new Result(['code' => 500, 'message' => $body, 'header' => $header]);
}
return $this->structure($this->resolve($header, $body), $data, $header);
return $this->structure($body, $data, $header);
} catch (\Exception $exception) {
return new Result(['code' => 500, 'message' => $exception->getMessage(), 'header' => []]);
}
}
/**
* @param $output
* @return array
*/
private function explode($output)
{
[$header, $body] = explode("\r\n\r\n", $output, 2);
$header = explode(PHP_EOL, $header);
unset($output);
$status = (int)explode(' ', trim($header[0]))[1];
$header = $this->headerFormat($header);
return [$header, $this->resolve($header, $body), $status];
}
/**
* @param $url
* @param $data