From f0c0fa56ad452708a1263c0eb773366c34f6e290 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Fri, 27 Oct 2023 17:18:47 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/foundation/web/WebClient.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/cokr/xit/foundation/web/WebClient.java b/src/main/java/cokr/xit/foundation/web/WebClient.java index 7aa4d7a..e6aca16 100644 --- a/src/main/java/cokr/xit/foundation/web/WebClient.java +++ b/src/main/java/cokr/xit/foundation/web/WebClient.java @@ -187,11 +187,15 @@ public class WebClient { } private HttpResponse handleRequest(boolean async, HttpRequest hreq, HttpResponse.BodyHandler bodyHandler, Consumer> respHandler) throws Exception { + Log.get(getClass()).debug("Sending request"); if (!async) { - return client().send(hreq, bodyHandler); + HttpResponse resp = client().send(hreq, bodyHandler); + Log.get(getClass()).debug("Received response"); + return resp; } else { CompletableFuture> future = client().sendAsync(hreq, bodyHandler); future.thenApply(resp -> { + Log.get(getClass()).debug("Received response"); respHandler.accept(resp); return resp; }); @@ -376,8 +380,7 @@ public class WebClient { */ public Request json(JSON json) { this.json = json; - contentType(ContentType.JSON); - return header("Accept", ContentType.JSON.type); + return contentType(ContentType.JSON); } private JSON json() { @@ -497,13 +500,13 @@ public class WebClient { HttpRequest post() { try { - HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(uri)); - builder.POST(bodyPublisher(contentType())); + HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(uri)); + builder.POST(bodyPublisher(contentType())); - if (headers != null) - headers.forEach((k, v) -> builder.header(k, v)); + if (headers != null) + headers.forEach((k, v) -> builder.header(k, v)); - return builder.build(); + return builder.build(); } catch (Exception e) { throw Assert.runtimeException(e); }