Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d9d761798 | |||
| 22f425ceb7 | |||
| a52610cf2a | |||
| 5697102a85 | |||
| 0c0a2fadd5 | |||
| 5061a17342 |
+1
-2
@@ -68,10 +68,9 @@ class CoroutineClient extends ClientAbstracts
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->execute($url, $data);
|
$this->execute($url, $data);
|
||||||
|
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->setStatusCode(-1);
|
$this->setStatusCode(-1);
|
||||||
$this->setBody(jTraceEx($exception));
|
$this->setBody(json_encode(['code' => 500, 'message' => $exception->getMessage()]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -155,11 +155,12 @@ class CurlClient extends ClientAbstracts
|
|||||||
{
|
{
|
||||||
$output = curl_exec($this->client);
|
$output = curl_exec($this->client);
|
||||||
if ($output !== FALSE) {
|
if ($output !== FALSE) {
|
||||||
$this->explode($this->client, $output);
|
$this->explode($output);
|
||||||
} else {
|
} else {
|
||||||
$this->setStatusCode(curl_errno($this->client));
|
$this->setStatusCode(curl_errno($this->client));
|
||||||
$this->setBody(curl_error($this->client));
|
$this->setBody(curl_error($this->client));
|
||||||
}
|
}
|
||||||
|
$this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -195,13 +196,13 @@ class CurlClient extends ClientAbstracts
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
private function explode($ch, string $output): void
|
private function explode(string $output): void
|
||||||
{
|
{
|
||||||
// 获取 HTTP 状态码
|
// 获取 HTTP 状态码
|
||||||
$statusCode = +curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$statusCode = +curl_getinfo($this->client, CURLINFO_HTTP_CODE);
|
||||||
|
|
||||||
// 获取 header 的大小(不包括最后的 \r\n\r\n 分隔符)
|
// 获取 header 的大小(不包括最后的 \r\n\r\n 分隔符)
|
||||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
$headerSize = curl_getinfo($this->client, CURLINFO_HEADER_SIZE);
|
||||||
$header = substr($output, 0, $headerSize);
|
$header = substr($output, 0, $headerSize);
|
||||||
if (in_array($statusCode, [502, 404])) {
|
if (in_array($statusCode, [502, 404])) {
|
||||||
$this->retry();
|
$this->retry();
|
||||||
|
|||||||
Reference in New Issue
Block a user