From a930f7cfc014daa9bd21865dc9f711dce78d3a8a Mon Sep 17 00:00:00 2001 From: swonny Date: Thu, 14 Sep 2023 21:17:17 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=88=84=EB=9D=BD=EB=90=9C=20ResponseHe?= =?UTF-8?q?aders=20=EC=BB=A4=EB=B0=8B=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http11/http/message/ResponseHeaders.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tomcat/src/main/java/org/apache/coyote/http11/http/message/ResponseHeaders.java diff --git a/tomcat/src/main/java/org/apache/coyote/http11/http/message/ResponseHeaders.java b/tomcat/src/main/java/org/apache/coyote/http11/http/message/ResponseHeaders.java new file mode 100644 index 0000000000..c03e72516b --- /dev/null +++ b/tomcat/src/main/java/org/apache/coyote/http11/http/message/ResponseHeaders.java @@ -0,0 +1,36 @@ +package org.apache.coyote.http11.http.message; + +import org.apache.coyote.http11.http.util.HttpResponseMessageHeader; + +import java.util.EnumMap; +import java.util.Map; + +public class ResponseHeaders { + + private static final String MESSAGE_HEADERS_DELIMITER = ": "; + private static final String SP = " "; + private static final String CRLF = "\r\n"; + + private final Map headerValues; + + public ResponseHeaders() { + this.headerValues = new EnumMap<>(HttpResponseMessageHeader.class); + } + + public void setAttribute(final HttpResponseMessageHeader headerType, final String value) { + headerValues.put(headerType, value); + } + + @Override + public String toString() { + final StringBuilder stringBuilder = new StringBuilder(); + for (final HttpResponseMessageHeader header : headerValues.keySet()) { + stringBuilder.append(header.getValue()) + .append(MESSAGE_HEADERS_DELIMITER) + .append(headerValues.get(header)) + .append(SP) + .append(CRLF); + } + return stringBuilder.toString(); + } +}