-
Notifications
You must be signed in to change notification settings - Fork 24
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
유저 객체를 생성하는 건 이 객체의 역할에 맞지는 않는 것 같네요. 그냥 생성자를 쓰셔도 될 것 같아요
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); | ||
} | ||
} |
There was a problem hiding this comment.
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을 바꾸는 식으로 말이죠.
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()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿠키가 추가되어야 하니 새로운 메소드를 만들었군요. 그런데 헤더의 값들을 Map 컬렉션으로 관리한다면 어떨까요? 그러면 쿠키를 추가해야한다면, Map에 Set-cookie을 추가하면 되겠죠! 그러면 좀 더 유연한 헤더 작성이 가능하지 않을까요?
아직 리팩이 많이 부족한 코드입니다 ..
빠른 시일 내에 추가 보완하겠습니다