修改漏洞问题-pc端已测试完成
This commit is contained in:
@@ -98,6 +98,10 @@ public class ChatClient {
|
||||
|
||||
// 逐行读取 SSE 格式的响应
|
||||
try (var bufferedSource = body.source()) {
|
||||
//判断 bufferedSource
|
||||
if (bufferedSource != null) {
|
||||
return;
|
||||
}
|
||||
while (!bufferedSource.exhausted()) {
|
||||
String chunk = bufferedSource.readUtf8Line();
|
||||
if (chunk != null && !chunk.trim().isEmpty()) {
|
||||
@@ -248,8 +252,12 @@ public class ChatClient {
|
||||
|
||||
// 发送同步请求
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (response == null) {
|
||||
return "请求失败,响应为空";
|
||||
}
|
||||
if (!response.isSuccessful()) {
|
||||
String errorBody = response.body() != null ? response.body().string() : "无错误信息";
|
||||
ResponseBody body = response.body();
|
||||
String errorBody = (body != null) ? body.string() : "无错误信息";
|
||||
String errorMsg = String.format("API 响应错误: 状态码=%d, 错误信息=%s",
|
||||
response.code(), errorBody);
|
||||
throw new IOException(errorMsg);
|
||||
|
||||
Reference in New Issue
Block a user