|
@@ -147,7 +147,7 @@ public class SpiderApiService {
|
|
|
// 2. 执行请求并解析响应(使用 try-with-resources 自动关闭响应流)
|
|
// 2. 执行请求并解析响应(使用 try-with-resources 自动关闭响应流)
|
|
|
try (Response response = client.newCall(request).execute()) {
|
|
try (Response response = client.newCall(request).execute()) {
|
|
|
if (!response.isSuccessful()) {
|
|
if (!response.isSuccessful()) {
|
|
|
- return new ResultWrapper<>(-1, null); // HTTP 状态码非 2xx,触发重试
|
|
|
|
|
|
|
+ return new ResultWrapper<>(response.code(), null); // HTTP 状态码非 2xx,触发重试
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String responseBody = response.body().string();
|
|
String responseBody = response.body().string();
|
|
@@ -190,7 +190,7 @@ public class SpiderApiService {
|
|
|
// 2. 执行请求并解析响应
|
|
// 2. 执行请求并解析响应
|
|
|
try (Response response = client.newCall(request).execute()) {
|
|
try (Response response = client.newCall(request).execute()) {
|
|
|
if (!response.isSuccessful()) {
|
|
if (!response.isSuccessful()) {
|
|
|
- return new ResultWrapper<>(-1, null); // HTTP状态码非2xx,返回失败状态码
|
|
|
|
|
|
|
+ return new ResultWrapper<>(response.code(), null); // HTTP状态码非2xx,返回失败状态码
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String responseBody = response.body().string();
|
|
String responseBody = response.body().string();
|
|
@@ -241,7 +241,7 @@ public class SpiderApiService {
|
|
|
|
|
|
|
|
try (Response response = client.newCall(request).execute()) {
|
|
try (Response response = client.newCall(request).execute()) {
|
|
|
if (!response.isSuccessful()) {
|
|
if (!response.isSuccessful()) {
|
|
|
- return new ResultWrapper<>(-1, null);
|
|
|
|
|
|
|
+ return new ResultWrapper<>(response.code(), null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String responseBody = response.body().string();
|
|
String responseBody = response.body().string();
|
|
@@ -300,7 +300,7 @@ public class SpiderApiService {
|
|
|
// 2. 执行请求并解析响应(使用 try-with-resources 自动关闭响应流)
|
|
// 2. 执行请求并解析响应(使用 try-with-resources 自动关闭响应流)
|
|
|
try (Response response = client.newCall(request).execute()) {
|
|
try (Response response = client.newCall(request).execute()) {
|
|
|
if (!response.isSuccessful()) {
|
|
if (!response.isSuccessful()) {
|
|
|
- return new ResultWrapper<>(-1, null); // HTTP 状态码非 2xx,返回失败状态码
|
|
|
|
|
|
|
+ return new ResultWrapper<>(response.code(), null); // HTTP 状态码非 2xx,返回失败状态码
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String responseBody = response.body().string();
|
|
String responseBody = response.body().string();
|