content type 설정 수정

master
mjkhan21 1 year ago
parent 63df12a22d
commit f35b0ba597

@ -258,7 +258,7 @@ public class WebClient {
if (Assert.isEmpty(type)) return null; if (Assert.isEmpty(type)) return null;
for (ContentType content: values()) for (ContentType content: values())
if (type.equals(content.type)) if (type.contains(content.type))
return content; return content;
throw new IllegalArgumentException(type); throw new IllegalArgumentException(type);
@ -296,7 +296,7 @@ public class WebClient {
} }
public Request contentType(ContentType type) { public Request contentType(ContentType type) {
return header("Content-Type", type.type); return header("Content-Type", type.type + "; charset=" + charset);
} }
private Request.ContentType contentType() { private Request.ContentType contentType() {
@ -430,10 +430,6 @@ public class WebClient {
HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(uri + queryString)) HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(uri + queryString))
.GET(); .GET();
ContentType contentType = contentType();
if (contentType != null)
builder.header("Content-Type", contentType.type + "; charset=" + charset);
if (headers != null) if (headers != null)
headers.forEach((k, v) -> builder.header(k, v)); headers.forEach((k, v) -> builder.header(k, v));
@ -466,11 +462,8 @@ public class WebClient {
HttpRequest post() { HttpRequest post() {
try { try {
ContentType contentType = contentType();
HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(uri)); HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(uri));
if (contentType != null) builder.POST(bodyPublisher(contentType()));
builder.header("Content-Type", contentType.type + "; charset=" + charset);
builder.POST(bodyPublisher(contentType));
if (headers != null) if (headers != null)
headers.forEach((k, v) -> builder.header(k, v)); headers.forEach((k, v) -> builder.header(k, v));

Loading…
Cancel
Save