-
Notifications
You must be signed in to change notification settings - Fork 311
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
[1-2단계 톰캣 구현하기] 비토(오상훈) 미션 제출합니다. #526
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 fileName = "static" + path; | ||
var resourceUrl = getClass().getClassLoader().getResource(fileName); | ||
Path filePath = Path.of(resourceUrl.toURI()); |
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.
존재하지 않는 경로에 대한 처리가 없어서 NullPointerException
발생합니다.
String requestBody = httpRequest.getBody(); | ||
String[] token = requestBody.split("&"); | ||
String account = token[0].split("=")[1]; | ||
String password = token[1].split("=")[1]; |
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.
로그인 페이지에서 input 값을 완전히 채우지 않고 POST
요청을 보내면 ArrayIndexOutOfBoundsException
예외가 발생합니다.
String requestBody = httpRequest.getBody(); | ||
String[] token = requestBody.split("&"); | ||
String account = token[0].split("=")[1]; | ||
String email = token[1].split("=")[1]; | ||
String password = token[2].split("=")[1]; |
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.
회원가입 페이지에서 input 값을 완전히 채우지 않고 POST
요청을 보내면 ArrayIndexOutOfBoundsException
예외가 발생합니다.
User user = new User(account, password, email); | ||
InMemoryUserRepository.save(user); |
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.
중복 회원가입이 가능한 상태입니다.
public RequestMapping() { | ||
controllers.put("/login", new LoginController()); | ||
controllers.put("/register", new RegisterController()); | ||
controllers.put("page", new PageController()); |
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.
로그인, 회원가입 페이지가 아니면 PageController
를 반환하고 있어서 controllers
에 page
를 넣을 필요가 없을 것 같네요.
Map<String, String> headers = httpResponseHeader.getHeaders(); | ||
StringBuilder sb = new StringBuilder(); | ||
int size = headers.keySet().size(); | ||
int i = 1; | ||
for (String key : headers.keySet()) { | ||
if (i < size) { | ||
sb.append(key).append(": ").append(headers.get(key)).append(" \r\n"); | ||
size++; | ||
} else { | ||
sb.append(key).append(": ").append(headers.get(key)); | ||
} | ||
} |
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.
HttpResponseHeader
객체에게 responseHeader를 요청하는게 어떨까요?
String[] cookies = httpRequest.getValue("Cookie").split("; "); | ||
String cookie = ""; | ||
for (String c : cookies) { | ||
if (c.contains("JSESSIONID")) { | ||
cookie = c.split("=")[1]; | ||
} | ||
} |
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.
어느 미친 사용자가 비토가 넣어준 JSESSIONID
값을 지우고 로그인 페이지로 접근했더니ArrayIndexOutOfBoundsException
예외가 발생했다네요.
String path = httpRequest.getPath(); | ||
if (!httpRequest.getPath().contains(".")) { | ||
path += ".html"; | ||
} |
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.
어느 미친 사용자가 서버 내부 에러를 발생시켰는데, 그 요청은 localhost:8080/500
이었어요.
; | ||
|
||
private final String contentType; | ||
private final String extention; |
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.
extension!
안녕하세요 이상! 비토입니다!
어느 정도 클래스 분리를 하긴했는데 아직 군데군데 리팩토링이 필요하긴 합니다.
천천히 리뷰 주세요.
리뷰 잘 부탁드립니다!