From 996efd6a4de67158c963a04c5c69a5b471b596ed Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Mon, 11 Sep 2023 21:47:09 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20Parser/Generator=EC=9D=98=20?= =?UTF-8?q?=EC=9D=B8=EC=8A=A4=ED=84=B4=EC=8A=A4=ED=99=94=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apache/coyote/http11/request/Http11RequestBodyParser.java | 3 +++ .../coyote/http11/request/Http11RequestHeaderParser.java | 3 +++ .../apache/coyote/http11/request/Http11RequestLineParser.java | 3 +++ .../coyote/http11/response/Http11ResponseHeaderGenerator.java | 3 +++ .../coyote/http11/response/Http11StatusLineGenerator.java | 3 +++ 5 files changed, 15 insertions(+) diff --git a/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestBodyParser.java b/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestBodyParser.java index ce0d52e0a6..f20ab7528a 100644 --- a/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestBodyParser.java +++ b/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestBodyParser.java @@ -11,6 +11,9 @@ public class Http11RequestBodyParser { private static final String DELIMITER = "&"; private static final String KEY_VALUE_SEPARATOR = "="; + private Http11RequestBodyParser() { + } + public static RequestBody parse(final String body) { if (body == null || body.isBlank()) { return RequestBody.empty(); diff --git a/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestHeaderParser.java b/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestHeaderParser.java index 99c18d365a..04b1d1b82b 100644 --- a/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestHeaderParser.java +++ b/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestHeaderParser.java @@ -16,6 +16,9 @@ public class Http11RequestHeaderParser { private static final String COOKIE_DELIMITER = "; "; private static final String COOKIE_KEY_VALUE_SEPARATOR = "="; + private Http11RequestHeaderParser() { + } + public static RequestHeader parse(final List requestHeaders) { final var headers = requestHeaders.stream() .map(header -> header.split(HEADER_SEPARATOR, 2)) diff --git a/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestLineParser.java b/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestLineParser.java index 346c86b720..d08e77d365 100644 --- a/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestLineParser.java +++ b/tomcat/src/main/java/org/apache/coyote/http11/request/Http11RequestLineParser.java @@ -17,6 +17,9 @@ public class Http11RequestLineParser { private static final String QUERY_PARAM_DELIMITER = "&"; private static final String KEY_VALUE_SEPARATOR = "="; + private Http11RequestLineParser() { + } + public static RequestLine parse(String requestLine) { final var parts = requestLine.split(REQUEST_LINE_DELIMITER); final var method = HttpMethod.from(parts[0]); diff --git a/tomcat/src/main/java/org/apache/coyote/http11/response/Http11ResponseHeaderGenerator.java b/tomcat/src/main/java/org/apache/coyote/http11/response/Http11ResponseHeaderGenerator.java index 987c262733..02ff957ac3 100644 --- a/tomcat/src/main/java/org/apache/coyote/http11/response/Http11ResponseHeaderGenerator.java +++ b/tomcat/src/main/java/org/apache/coyote/http11/response/Http11ResponseHeaderGenerator.java @@ -17,6 +17,9 @@ public class Http11ResponseHeaderGenerator { private static final String COOKIE_KEY_VALUE_SEPARATOR = "="; private static final String LINE_END = " "; + private Http11ResponseHeaderGenerator() { + } + public static String generate(final ResponseHeader responseHeader) { final var headers = responseHeader.getHeaders(); final var cookies = responseHeader.getCookies(); diff --git a/tomcat/src/main/java/org/apache/coyote/http11/response/Http11StatusLineGenerator.java b/tomcat/src/main/java/org/apache/coyote/http11/response/Http11StatusLineGenerator.java index 93a396ad82..1c5aba11a3 100644 --- a/tomcat/src/main/java/org/apache/coyote/http11/response/Http11StatusLineGenerator.java +++ b/tomcat/src/main/java/org/apache/coyote/http11/response/Http11StatusLineGenerator.java @@ -7,6 +7,9 @@ public class Http11StatusLineGenerator { private static final String STATUS_LINE_DELIMITER = " "; private static final String LINE_END = " "; + private Http11StatusLineGenerator() { + } + public static String generate(final StatusLine statusLine) { final var version = statusLine.getVersion().getVersion(); final var code = statusLine.getCode();