add clear
This commit is contained in:
+19
-6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user