diff --git a/tomcat/src/main/java/org/apache/coyote/http11/http/ResponseEntity.java b/tomcat/src/main/java/org/apache/coyote/http11/http/ResponseEntity.java index 63dd427497..ac0a2c799a 100644 --- a/tomcat/src/main/java/org/apache/coyote/http11/http/ResponseEntity.java +++ b/tomcat/src/main/java/org/apache/coyote/http11/http/ResponseEntity.java @@ -11,6 +11,9 @@ public class ResponseEntity { + public static final String EXTENSION_DELIMITER = "."; + public static final String RESPONSE_DELIMITER = " "; + private final HttpVersion httpVersion; private final ResponseStatus responseStatus; private final List responseHeaders; @@ -25,12 +28,12 @@ public ResponseEntity(HttpVersion httpVersion, ResponseStatus responseStatus, Li } public static ResponseEntity redirect(String redirectionFile) { - List headers = List.of(String.join(" ", "Location:", redirectionFile)); + List headers = List.of(String.join(RESPONSE_DELIMITER, "Location:", redirectionFile)); return new ResponseEntity(HttpVersion.HTTP_1_1, ResponseStatus.FOUND, headers, ""); } public static ResponseEntity ok(String fileData, String endPoint) { - int fileTypeStartIndex = endPoint.indexOf('.'); + int fileTypeStartIndex = endPoint.indexOf(EXTENSION_DELIMITER); String fileExtension = endPoint.substring(fileTypeStartIndex + 1); List headers = List.of( @@ -56,7 +59,7 @@ public String generateResponseMessage() { private String generateStatus() { return String.join( - " ", + RESPONSE_DELIMITER, httpVersion.getVersion(), String.valueOf(responseStatus.getStatusCode()), responseStatus.name(), @@ -68,7 +71,7 @@ private String generateHeader() { StringJoiner headers = new StringJoiner("\r\n"); for (String header : responseHeaders) { headers.add( - String.join(" ", header, "") + String.join(RESPONSE_DELIMITER, header, "") ); } if (cookies.containsKey("JSESSIONID")) {