Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3주차 미션 / 서버 3조 김윤서 #11

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

yskim6772
Copy link
Member

@yskim6772 yskim6772 commented Oct 4, 2024

아직 리팩이 많이 부족한 코드입니다 ..
빠른 시일 내에 추가 보완하겠습니다

Copy link

@JangIkhwan JangIkhwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정말 고생하셨어요! 👍 어려운 미션이었던만큼 완성 코드와 비교하면서 공부해보면 큰 도움이 될 거예요!

String body = IOUtils.readData(br, contentLength);
Map<String, String> queryParameter = HttpRequestUtils.parseQueryParameter(body);

User user = createUserFromQuery(queryParameter);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

유저 객체를 생성하는 건 이 객체의 역할에 맞지는 않는 것 같네요. 그냥 생성자를 쓰셔도 될 것 같아요

Comment on lines +223 to +232
private void handleCssResponse(DataOutputStream dos, String requestPath) {
String filePath = WEB_ROOT + requestPath;
byte[] body = readFile(filePath);
if (body != null) {
response200CssHeader(dos, body.length);
responseBody(dos, body);
} else {
log.log(Level.SEVERE, "CSS file not found: " + requestPath);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleFileResponse 메소드에서 css를 처리할 수 있지 않을까요? 확장자가 .css인지 확인해서 헤더에 들어갈 content type을 바꾸는 식으로 말이죠.

Comment on lines +264 to +273
private void response302WithCookieHeader(DataOutputStream dos, String location, String cookie) {
try {
dos.writeBytes("HTTP/1.1 302 Found \r\n");
dos.writeBytes("Location: " + location + "\r\n");
dos.writeBytes("Set-Cookie: " + cookie + "\r\n");
dos.writeBytes("\r\n");
} catch (IOException e) {
log.log(Level.SEVERE, e.getMessage());
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쿠키가 추가되어야 하니 새로운 메소드를 만들었군요. 그런데 헤더의 값들을 Map 컬렉션으로 관리한다면 어떨까요? 그러면 쿠키를 추가해야한다면, Map에 Set-cookie을 추가하면 되겠죠! 그러면 좀 더 유연한 헤더 작성이 가능하지 않을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants