while(!(line = bufferedReader.readLine()).isEmpty()) {
HttpRequestUtils.Pair pair = HttpRequestUtils.parseHeader(line);
header.put(pair.getKey(), pair.getValue());
System.out.println(line);
}
if(request[0].equals("GET") && request[1].contains("?")) {
requestBody = request[1].split("\\?")[1];
} else if(request[0].equals("POST")) {
// Content-Length 헤더를 통해 본문의 길이를 파악
String contentLengthValue = header.get("Content-Length");
if (contentLengthValue != null) {
int contentLength = Integer.parseInt(contentLengthValue);
char[] body = new char[contentLength];
bufferedReader.read(body, 0, contentLength);
requestBody = new String(body);
}
}
body는 헤더 다음으로 온다.
body의 length를 파악 한 후에 body의 length 만큼 받아야한다.