@@ -134,54 +134,54 @@ public class SearchImageService {
|
|||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
// try (Response response = client.newCall(request).execute()) {
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
ResponseBody body = response.body();
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
|
log.info("Search reverse response body: {}", body);
|
||||||
// long duration = System.currentTimeMillis() - start;
|
// long duration = System.currentTimeMillis() - start;
|
||||||
// log.info("SearchAPI response code={}, duration={}ms, engine={}",
|
// log.info("SearchAPI response code={}, duration={}ms, engine={}",
|
||||||
// response.code(), duration, engine);
|
// response.code(), duration, engine);
|
||||||
//
|
|
||||||
// if (!response.isSuccessful()) {
|
// if (!response.isSuccessful()) {
|
||||||
// String errorBody = response.body() != null ? response.body().string() : "null";
|
// String errorBody = response.body() != null ? response.body().string() : "null";
|
||||||
// throw new IOException("API error " + response.code() + ": " + errorBody);
|
// throw new IOException("API error " + response.code() + ": " + errorBody);
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// ResponseBody body = response.body();
|
// ResponseBody body = response.body();
|
||||||
// if (body == null) {
|
|
||||||
// throw new IOException("Empty response body");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return body.string();
|
|
||||||
// }
|
|
||||||
|
|
||||||
try (Response response = client.newCall(request).execute()) {
|
|
||||||
long duration = System.currentTimeMillis() - start;
|
|
||||||
log.info("SearchAPI response code={}, duration={}ms, engine={}",
|
|
||||||
response.code(), duration, engine);
|
|
||||||
|
|
||||||
ResponseBody body = response.body();
|
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
throw new IOException("Empty response body");
|
throw new IOException("Empty response body");
|
||||||
}
|
}
|
||||||
|
|
||||||
String responseBody = readWithTimeout(body, 30000);
|
return body.string();
|
||||||
|
|
||||||
log.info("Read {} bytes (may be partial)", responseBody.length());
|
|
||||||
|
|
||||||
if (responseBody.length() > 0) {
|
|
||||||
String preview = responseBody.length() > 500 ?
|
|
||||||
responseBody.substring(0, 500) + "..." : responseBody;
|
|
||||||
log.info("Response preview: {}", preview);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!response.isSuccessful()) {
|
|
||||||
throw new IOException("API error " + response.code() + ": " +
|
|
||||||
(responseBody.length() > 200 ? responseBody.substring(0, 200) : responseBody));
|
|
||||||
}
|
|
||||||
|
|
||||||
return responseBody;
|
|
||||||
|
|
||||||
} catch (InterruptedIOException e) {
|
|
||||||
log.error("Timeout during reading, partial data may be lost");
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user