mirror of
https://github.com/foss42/apidash.git
synced 2025-06-27 19:07:40 +08:00
added java future for response handling
This commit is contained in:
@ -50,29 +50,20 @@ public class Main {
|
|||||||
.setBody(bodyContent)\n
|
.setBody(bodyContent)\n
|
||||||
''';
|
''';
|
||||||
|
|
||||||
final String kTemplateRequestEnd = """
|
final String kTemplateRequestEnd = '''
|
||||||
.build();
|
Future<Response> whenResponse = requestBuilder.execute();
|
||||||
ListenableFuture<Response> listenableFuture = asyncHttpClient.executeRequest(request);
|
Response response = whenResponse.get();
|
||||||
listenableFuture.addListener(() -> {
|
InputStream is = response.getResponseBodyAsStream();
|
||||||
try {
|
BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||||
Response response = listenableFuture.get();
|
String respBody = br.lines().collect(Collectors.joining("\\n"));
|
||||||
InputStream is = response.getResponseBodyAsStream();
|
System.out.println(response.getStatusCode());
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
System.out.println(respBody);
|
||||||
String respBody = br.lines().collect(Collectors.joining("\\n"));
|
|
||||||
System.out.println(response.getStatusCode());
|
|
||||||
System.out.println(respBody);
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}, Executors.newCachedThreadPool());
|
|
||||||
listenableFuture.get();
|
|
||||||
} catch (InterruptedException | ExecutionException | IOException ignored) {
|
} catch (InterruptedException | ExecutionException | IOException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}\n
|
||||||
\n
|
''';
|
||||||
""";
|
|
||||||
|
|
||||||
String? getCode(
|
String? getCode(
|
||||||
RequestModel requestModel,
|
RequestModel requestModel,
|
||||||
|
Reference in New Issue
Block a user