|
|
@@ -145,7 +145,7 @@ class ReproduceErrorCommand extends Command
|
|
|
|
|
|
// 输出结果
|
|
|
$this->line("响应内容:");
|
|
|
- dump(json_decode($response['body'], true));
|
|
|
+ $this->displayResponse($response, $requestData['type']);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -445,6 +445,41 @@ class ReproduceErrorCommand extends Command
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 显示响应内容
|
|
|
+ *
|
|
|
+ * @param array $response 响应数据
|
|
|
+ * @param string $requestType 请求类型
|
|
|
+ */
|
|
|
+ protected function displayResponse(array $response, string $requestType): void
|
|
|
+ {
|
|
|
+ $this->line("状态码: " . $response['status_code']);
|
|
|
+
|
|
|
+ if ($requestType === 'json') {
|
|
|
+ // JSON 响应,尝试解析
|
|
|
+ $jsonData = json_decode($response['body'], true);
|
|
|
+ if ($jsonData !== null) {
|
|
|
+ dump($jsonData);
|
|
|
+ } else {
|
|
|
+ $this->warn("响应不是有效的 JSON 格式");
|
|
|
+ $this->line("原始响应: " . substr($response['body'], 0, 500) . "...");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // Protobuf 二进制响应
|
|
|
+ $this->line("二进制响应长度: " . strlen($response['body']) . " 字节");
|
|
|
+ $this->line("Base64 编码: " . substr(base64_encode($response['body']), 0, 200) . "...");
|
|
|
+
|
|
|
+ // 尝试解析为 JSON(某些情况下服务器可能返回 JSON)
|
|
|
+ $jsonData = json_decode($response['body'], true);
|
|
|
+ if ($jsonData !== null) {
|
|
|
+ $this->line("响应可解析为 JSON:");
|
|
|
+ dump($jsonData);
|
|
|
+ } else {
|
|
|
+ $this->line("响应为二进制 Protobuf 数据,无法直接显示");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 清空当前日志文件
|
|
|
*/
|