Skip to content

Commit

Permalink
refactor: Parser/Generator의 인스턴스화 방지
Browse files Browse the repository at this point in the history
  • Loading branch information
xxeol2 committed Sep 11, 2023
1 parent c0fc346 commit 996efd6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> requestHeaders) {
final var headers = requestHeaders.stream()
.map(header -> header.split(HEADER_SEPARATOR, 2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 996efd6

Please sign in to comment.