-
Notifications
You must be signed in to change notification settings - Fork 309
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, 4단계] 케로(김지현) 미션 제출합니다. #480
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.
안녕하세요 케로! 바론입니다 🙇 🙇♀️
1, 2 단계 코드도 구조가 워낙 잘 잡혀있었어서 3단계에서 구조적으로 크게 변한점은 없고 코드가 더 깔끔해졌네용! 👍 👍
몇 가지 질문만 남겨두었습니당 ㅎ.ㅎ
너무 고생하셨습니다~~!! ❤️ 😍
httpResponse.setViewPathAsBodyAndSetStatus(httpRequest.getPath(), ResponseStatus.MOVED_TEMP); | ||
httpResponse.setRedirect("/index.html"); | ||
httpResponse.addCookie(Cookie.ofJSessionId(session.getId())); | ||
return; |
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.
로그인에 성공하면 302 헤더와 함께 index.html 로 redirect 하도록 응답을 보내는 것 같아요!
요 상황에서 serViewPathAsBody
를 따로 설정하신 이유가 있나용?.?
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.
헉 그러게요...
필요없이 response에 login.html을 담고 있었네여...
수정했습니다
private ResponseEntity loginPage(final Request request) { | ||
final Session session = request.getSession(false); | ||
private void loginPage(final HttpRequest httpRequest, final HttpResponse httpResponse) { | ||
final Session session = httpRequest.getSession(false); |
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.
getSession(boolean)
에 들어가는 파라미터가 어떤 의미를 가지는 값인지 알 수 있을까요?.?
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.
getSession의 메서드 파라미터 명을 수정하여 다시 작성했습니다.
도 실제 request session에서 처럼 true 일 때 기존 세션이 존재하지 않으면 새로 생성하고, false에서 존재하지 않으면 null을 반환하도록 수정했습니다
httpResponse.setViewPathAsBodyAndSetStatus(httpRequest.getPath(), ResponseStatus.MOVED_TEMP); | ||
httpResponse.setRedirect("/index.html"); | ||
return; |
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.
59번 라인의 코멘트와 동일합니다!
httpResponse.setViewPathAsBodyAndSetStatus(httpRequest.getPath(), ResponseStatus.MOVED_TEMP); | ||
httpResponse.setRedirect("/index.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.
위의 코멘트와 동일합니다 😄
private static final int DEFAULT_ACCEPT_COUNT = 30; | ||
private static final int DEFAULT_MAX_THREAD = 30; |
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.
이렇게 제한을 두신 이유가 궁금하네용 ㅎㅎ 케로가 코멘트에 말씀해주신 것 처럼 스레드에 대해서 더 공부하시게 된다면... 저도 알려주세용 (@^0^@)/
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.
일단 로컬에서 돌리고 있기 때문에 많은 스레드를 둘 필요가 없다고 판단해서 처음에 10개를 사용하였는데, ci에서 테스트가 깨져서 스레드 풀 개수 때문일가?? 하고 30까지 수정했던것 입니다....ㅎㅅㅎ
아직도 잘 모르겠어요 ...ㅠㅠ
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.
사실 저도 잘 모르겠어용 ㅋㅋㅋㅋ 근데 지금 미션 상황에서는 케로 말씀대로 많은 accept count와 thread가 필요하지 않을 것 같아요!
(공부한 내용 공유해달라고 꼬드기는 코멘트 였습니당 ㅎㅋㅎㅎ)
|
||
public class HttpResponse { | ||
|
||
private final ResponseStartLine responseStartLine; |
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.
this.httpVersion = httpVersion; | ||
this.status = status; | ||
this.status = ResponseStatus.OK; |
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.
궁금!!! Response Status를 기본적으로 OK로 설정해두신 이유가 궁금해요~~~
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.
Response의 기본 설정들이 setter로 바뀌면서 널 값을 방지하기 위하여 기본 값으로 Http 응답에 가장 많이 쓰이는 ok 상태코드로 지정해주었습니다 ㅎㅅㅎ
private final StaticMapping staticMapping; | ||
|
||
private final DynamicController dynamicController; | ||
private final RequestMapping requestMapping; | ||
|
||
public Proxy() { | ||
this.staticController = StaticController.singleTone(); | ||
this.dynamicController = DynamicController.singleTone(); | ||
this.staticMapping = new StaticMapping(); | ||
this.requestMapping = new RequestMapping(); |
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.
궁금해서 남기는 질문입니당! Static Mapping과 RequestMapping 필드를 static이 아닌, Proxy 객체 생성 시에 함께 생성하는 이유가 무엇인지 궁금해요~!
1 Proxy - 1 Mapping으로 관리가 되어야 하는건가요?.?
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.
1 Proxy - 1 Mapping 로 관리되지 않아도 될 것 같아서 처음에는 싱글톤 패턴으로 구현했다가,
리팩하는 과정에서 실수한 것 같습니다... ㅠㅠ
@Override | ||
public ResponseEntity handle(final Request request) { | ||
return ResponseEntity.fromString(request, "Hello world!", ResponseStatus.OK); | ||
protected void doGet(final HttpRequest request, final HttpResponse response) { | ||
response.setStringAsBody("Hello world!"); | ||
} |
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.
HelloWorldController에 doPost()
요청이 들어오면 어떻게 되나요?.?
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.
피알 날리고 궁금해서 해봤는데 NPE 가 발생하더라고여...
이부분도 처리 처리되도록 수정하였습니다 !
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.
안녕하세요 케로~~~ 바론입니다~~~!!!!
빠른 코멘트 답변과 완벽한 수정,,, 박수갈채 보냅니다 👏 👏 👏
이번 미션의 요구 사항을 모두 만족하신 것 같아서 merge합니다 💯 👍
너무 고생하셨습니다~~ 다음 미션도 화이팅이에요!
@Override | ||
protected void doPost(final HttpRequest request, final HttpResponse response) { | ||
throw new MethodMappingFailException(); | ||
} | ||
|
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.
따봉 👍
final Session session = Session.create(); | ||
SessionManager.add(session); | ||
return session; | ||
public Session getSession(final boolean create) { |
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.
따따봉 👍
@@ -65,10 +65,10 @@ private void login(final HttpRequest httpRequest, final HttpResponse httpRespons | |||
} | |||
|
|||
private void loginPage(final HttpRequest httpRequest, final HttpResponse httpResponse) { | |||
final Session session = httpRequest.getSession(false); | |||
final Session session = httpRequest.getSession(true); |
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.
케로의 getSession(true)
는 다음과 같은 흐름인 것 같은데,
- 이미 저장되어 있던 세션이라면 user 를 담은 세션이 반환되고
- 새롭게 생성된 세션이라면 user를 담고 있지 않는 세션을 반환한다.
loginPage
에서 로그인 여부에 따라 반환할 페이지를 다르게 설정할 때 getSession(false)
를 한 후, session == null
여부로 판단하지 않고, 항상 Session이 만들어지고 나서 그 내부의 Optional<User>
여부로 판단하도록 구성하신 이유가 궁금해용!!
Kudos, SonarCloud Quality Gate passed! 0 Bugs 0.0% Coverage The version of Java (11.0.20.1) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17. |
바론 -- !
늘 꼼꼼한 리뷰 감사합니다람쥐 ◠‿◠
1,2 단계에서 리팩 빡시게 해서 3단계에 큰 구조적 변화는 없습니다만...
그래도 파일 체인지는 많네유 ㅠㅠ
4단계 스레드 부분은 아직 잘 몰라서...
점차 알아나가면서 개선해가겠습니다....
(로컬에서는 잘 돌아가는데 ci시 STANDARD_OUT이 발생하여 주석 처리 된 테스트가 존재합니다)