Skip to content

Commit

Permalink
Commments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRuiz7 committed Oct 23, 2024
1 parent d643f1f commit 428b365
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ private RestChannelConsumer handlePost(RestRequest request) throws IOException {
.toString();
SimpleHttpResponse response =
HttpRestClientDemo.runWithResponse(receiverURI, payload, document.getId());

// SimpleHttpResponse response = httpClient.post(receiverURI, payload,
// document.getId());
log.info("Received response to POST request with code [{}]", response.getCode());
log.info("Raw response:\n{}", response.getBodyText());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ public class HttpRestClientDemo {
* @param endpoint POST's requests endpoint as a well-formed URI
* @param body POST's request body as a JSON string.
*/
// public static void run(String endpoint, String body) {
// log.info("Executing POST request");
// AccessController.doPrivileged(
// (PrivilegedAction<SimpleHttpResponse>)
// () -> {
// HttpRestClient httpClient = HttpRestClient.getInstance();
// try {
// URI host = new URIBuilder(endpoint).build();
// SimpleHttpResponse response =
// httpClient.post(host, body, "randomId");
// log.info(
// "Received response to POST request with code {}",
// response.getCode());
// log.info("Raw response:\n{}", response.getBodyText());
// } catch (URISyntaxException e) {
// log.error("Bad URI:{}", e.getMessage());
// } catch (Exception e) {
// log.error("Error reading response: {}", e.getMessage());
// }
// return null;
// });
// }
public static void run(String endpoint, String body) {
log.info("Executing POST request");
AccessController.doPrivileged(
(PrivilegedAction<SimpleHttpResponse>)
() -> {
HttpRestClient httpClient = HttpRestClient.getInstance();
try {
URI host = new URIBuilder(endpoint).build();
SimpleHttpResponse response =
httpClient.post(host, body, "randomId");
log.info(
"Received response to POST request with code {}",
response.getCode());
log.info("Raw response:\n{}", response.getBodyText());
} catch (URISyntaxException e) {
log.error("Bad URI:{}", e.getMessage());
} catch (Exception e) {
log.error("Error reading response: {}", e.getMessage());
}
return null;
});
}

/**
* Demo method to test the {@link HttpRestClient} class.
Expand Down

0 comments on commit 428b365

Please sign in to comment.