Skip to content

Conversation

@pricelees
Copy link

프린 안녕하세요! 제출이 늦어서 죄송합니다 ㅎㅎ;;

전에 말씀드린대로 코드가 다 바뀌었어요..ㅎㅎ.. 분량이 많아져서 죄송해요.

시간 여유 생기면 커피라도 대접하겠습니다 🙇 귀한 시간 내주셔서 감사해요 😄

geoje and others added 27 commits September 11, 2024 11:31
@pricelees pricelees requested a review from GIVEN53 September 12, 2024 07:20
Copy link
Member

@GIVEN53 GIVEN53 left a comment

Choose a reason for hiding this comment

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

안녕하세요 상돌~ 구현하느라 고생 많으셨습니다
크리티컬한 오류가 있어서 확인 부탁드려요
탭 사이즈도 확인해주세요!

  1. 브라우저에 세션이 없을 때 GET /login 요청 시
    스크린샷 2024-09-12 오후 6 18 03
스크린샷 2024-09-12 오후 6 20 03



  1. POST /login 요청 시 Set-Cookie 헤더 누락
    스크린샷 2024-09-12 오후 8 41 30

private WebContentInterceptor getNoCacheInterceptor() {
CacheControl cacheControl = CacheControl.noCache().cachePrivate();

return createWebContentInterceptorByCache(cacheControl, "/");
Copy link
Member

Choose a reason for hiding this comment

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

루트 경로에만 적용되지 않을까요?

Copy link
Author

Choose a reason for hiding this comment

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

루트 경로에만 적용되지 않을까요?

학습 테스트의 testNoCachePrivate()가 휴리스틱 캐싱을 적용해보는 것이 의도라고 생각해서 정해진 경로만 지정하였습니다 😄

final var tomcat = new Tomcat();
tomcat.start();
}
public static void main(String[] args) {
Copy link
Member

Choose a reason for hiding this comment

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

탭사이즈 몇으로 사용하고 계신가요??

Copy link
Author

Choose a reason for hiding this comment

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

탭사이즈 몇으로 사용하고 계신가요??

4로 사용하고 있습니다 ㅎㅎ 탭사이즈에 제약이 있었나용?

Copy link
Member

Choose a reason for hiding this comment

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

제약은 없는걸로 아는데 원래 있던 코드의 탭 사이즈가 달라져서 여쭤봤어요!

Copy link
Author

Choose a reason for hiding this comment

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

제약은 없는걸로 아는데 원래 있던 코드의 탭 사이즈가 달라져서 여쭤봤어요!

인텔리제이 포맷 파일을 https://naver.github.io/hackday-conventions-java/ 를 쓰고있어요😄

}

default HttpResponse redirect(HttpResponseHeader header, String location) {
header.addHeader("Location", location);
Copy link
Member

Choose a reason for hiding this comment

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

상수로 추출해볼까요? 헤더 관련 상수가 이곳저곳 흩어져있다면 enum으로 관리해도 좋겠습니다

Copy link
Author

Choose a reason for hiding this comment

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

상수로 추출해볼까요? 헤더 관련 상수가 이곳저곳 흩어져있다면 enum으로 관리해도 좋겠습니다

해당 클래스와 직접적으로 연관이 있다고 판단되는 값만 상수로 지정하게 되었는데.. 관리 포인트를 생각하면 enum으로 정의하는게 낫겠네요~~! 바로 반영할게요😄

return handlers.stream()
.filter(handler -> handler.isSupport(requestLine))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("handler not found. " +
Copy link
Member

Choose a reason for hiding this comment

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

Http11Processor에서 IllegalArgumentException을 처리하지 않고 있습니다
예외대신 404 페이지를 바라보는 NotFoundHandler를 구현해서 리턴하면 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

Http11Processor에서 IllegalArgumentException을 처리하지 않고 있습니다 예외대신 404 페이지를 바라보는 NotFoundHandler를 구현해서 리턴하면 어떨까요?

텔레파시 🤜🤛

return new HttpResponse(new HttpResponseStartLine(HTTP_VERSION, HttpStatusCode.OK), header, body);
}

public static HttpResponse notFound(HttpResponseHeader header, HttpResponseBody body) {
Copy link
Member

Choose a reason for hiding this comment

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

ok()와 더불어서, usages를 확인했을 때 모두 추가적인 로직없이 단순히 외부에서 header 객체를 생성 후 넘겨주고 있습니다
이렇게 구현하신 이유가 있을까요??

Copy link
Author

Choose a reason for hiding this comment

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

ok()와 더불어서, usages를 확인했을 때 모두 추가적인 로직없이 단순히 외부에서 header 객체를 생성 후 넘겨주고 있습니다 이렇게 구현하신 이유가 있을까요??

음 지금은 응답 헤더에 값을 넣고있지 않는데 헤더에 값을 넣을 여지는 열어놔야 한다고 생각했읍니다 ~~!

void findHandler_WhenRequestRootPage() {
String requestPath = "/";

Class<? extends Handler> expectedHandler = RootPageHandler.class;
Copy link
Member

Choose a reason for hiding this comment

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

제네릭인 이유가 있나요?? Handler 인터페이스로 선언해도 되지 않을까요?

Copy link
Author

Choose a reason for hiding this comment

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

제네릭인 이유가 있나요?? Handler 인터페이스로 선언해도 되지 않을까요?

테스트에서 타입 비교에 사용되는데, 이 경우는 제네릭을 안 쓰면 구체 타입을 지정해야 하더라구요. 그런데 생각해보니 runTest의 파라미터만 제네릭을 써도 충분해서 구체 타입을 지정하는 방법으로 수정했습니다😄


Handler handler = HandlerMapper.findHandler(request);

assertThat(handler).isInstanceOf(expectedHandler);
Copy link
Member

Choose a reason for hiding this comment

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

isExactlyInstanceOf()로 클래스가 정확히 일치하는지 검증하면 신뢰도가 더 높을 것 같습니다

Copy link
Author

Choose a reason for hiding this comment

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

isExactlyInstanceOf()로 클래스가 정확히 일치하는지 검증하면 신뢰도가 더 높을 것 같습니다

쵝오..😌

@@ -0,0 +1,106 @@
<!DOCTYPE html>
Copy link
Member

Choose a reason for hiding this comment

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

이 html 파일은 어떤 용도인가요?

Copy link
Author

Choose a reason for hiding this comment

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

이 html 파일은 어떤 용도인가요?

getPath() 에서 NPE가 나오길래 파일을 넣었는데.. 제가 경로 설정을 잘못했군요..ㅎㅎ..

}

private void validateIsNotEmptyValue(String account, String password, String email) {
if (account == null || account.isBlank()) {
Copy link
Member

Choose a reason for hiding this comment

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

user 검증 추가 좋네요 👍🏻

Copy link
Author

Choose a reason for hiding this comment

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

user 검증 추가 좋네요 👍🏻

감사링 ㅎㅎ

return null;
}

LinkedHashMap<String, List<String>> result = new LinkedHashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

구체적인 하위 타입을 선언하신 이유가 있을까요?

Copy link
Author

Choose a reason for hiding this comment

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

구체적인 하위 타입을 선언하신 이유가 있을까요?

제가 에러 휴먼이라서요..? ㅋㅋㅋ 감사합니닷

Copy link
Member

Choose a reason for hiding this comment

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

아니요? 상돌은 핸섬 휴먼입니다

Copy link
Author

Choose a reason for hiding this comment

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

아니요? 상돌은 핸섬 휴먼입니다

ㅋㅋㅋㅋㅋ 영광이에요 ㅋㅋㅋㅋ

Copy link
Author

@pricelees pricelees left a comment

Choose a reason for hiding this comment

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

뿌링 안녕하세요~
남겨주신 의견들에 모두 답글 남겨놨고, 반영이 필요한 부분은 모두 반영했습니다.
(커밋을 커멘트 단위로 해서 커밋 로그를 보시는 것도 좋을 것 같아요!)

바쁜 와중에서도 디테일한 리뷰 감사합니다~~🙇

private WebContentInterceptor getNoCacheInterceptor() {
CacheControl cacheControl = CacheControl.noCache().cachePrivate();

return createWebContentInterceptorByCache(cacheControl, "/");
Copy link
Author

Choose a reason for hiding this comment

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

루트 경로에만 적용되지 않을까요?

학습 테스트의 testNoCachePrivate()가 휴리스틱 캐싱을 적용해보는 것이 의도라고 생각해서 정해진 경로만 지정하였습니다 😄

final var tomcat = new Tomcat();
tomcat.start();
}
public static void main(String[] args) {
Copy link
Author

Choose a reason for hiding this comment

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

탭사이즈 몇으로 사용하고 계신가요??

4로 사용하고 있습니다 ㅎㅎ 탭사이즈에 제약이 있었나용?

}

private void validateIsNotEmptyValue(String account, String password, String email) {
if (account == null || account.isBlank()) {
Copy link
Author

Choose a reason for hiding this comment

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

user 검증 추가 좋네요 👍🏻

감사링 ㅎㅎ

}

default HttpResponse redirect(HttpResponseHeader header, String location) {
header.addHeader("Location", location);
Copy link
Author

Choose a reason for hiding this comment

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

상수로 추출해볼까요? 헤더 관련 상수가 이곳저곳 흩어져있다면 enum으로 관리해도 좋겠습니다

해당 클래스와 직접적으로 연관이 있다고 판단되는 값만 상수로 지정하게 되었는데.. 관리 포인트를 생각하면 enum으로 정의하는게 낫겠네요~~! 바로 반영할게요😄

return handlers.stream()
.filter(handler -> handler.isSupport(requestLine))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("handler not found. " +
Copy link
Author

Choose a reason for hiding this comment

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

Http11Processor에서 IllegalArgumentException을 처리하지 않고 있습니다 예외대신 404 페이지를 바라보는 NotFoundHandler를 구현해서 리턴하면 어떨까요?

텔레파시 🤜🤛

return new HttpResponse(new HttpResponseStartLine(HTTP_VERSION, HttpStatusCode.OK), header, body);
}

public static HttpResponse notFound(HttpResponseHeader header, HttpResponseBody body) {
Copy link
Author

Choose a reason for hiding this comment

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

ok()와 더불어서, usages를 확인했을 때 모두 추가적인 로직없이 단순히 외부에서 header 객체를 생성 후 넘겨주고 있습니다 이렇게 구현하신 이유가 있을까요??

음 지금은 응답 헤더에 값을 넣고있지 않는데 헤더에 값을 넣을 여지는 열어놔야 한다고 생각했읍니다 ~~!

return new HttpResponse(new HttpResponseStartLine(HTTP_VERSION, HttpStatusCode.NOT_FOUND), header, body);
}

public HttpResponse(HttpResponseStartLine startLine, HttpResponseHeader header, HttpResponseBody body) {
Copy link
Author

Choose a reason for hiding this comment

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

객체 내부에서만 사용하는 생성자는 private 접근 제어자를 사용하면 어떨까요?

ok, notfound 등이 이후에 추가한 것들이라 반영이 다 안되었네요..ㅎㅎ 수정했습니다👍

void findHandler_WhenRequestRootPage() {
String requestPath = "/";

Class<? extends Handler> expectedHandler = RootPageHandler.class;
Copy link
Author

Choose a reason for hiding this comment

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

제네릭인 이유가 있나요?? Handler 인터페이스로 선언해도 되지 않을까요?

테스트에서 타입 비교에 사용되는데, 이 경우는 제네릭을 안 쓰면 구체 타입을 지정해야 하더라구요. 그런데 생각해보니 runTest의 파라미터만 제네릭을 써도 충분해서 구체 타입을 지정하는 방법으로 수정했습니다😄


Handler handler = HandlerMapper.findHandler(request);

assertThat(handler).isInstanceOf(expectedHandler);
Copy link
Author

Choose a reason for hiding this comment

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

isExactlyInstanceOf()로 클래스가 정확히 일치하는지 검증하면 신뢰도가 더 높을 것 같습니다

쵝오..😌

@@ -0,0 +1,106 @@
<!DOCTYPE html>
Copy link
Author

Choose a reason for hiding this comment

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

이 html 파일은 어떤 용도인가요?

getPath() 에서 NPE가 나오길래 파일을 넣었는데.. 제가 경로 설정을 잘못했군요..ㅎㅎ..

@pricelees
Copy link
Author

POST /login 요청 시 Set-Cookie 헤더 누락

이미 로그인이 되어 있으면 POST /login 요청을 보낼 일이 없다고 생각했으나.. 로그인 마다 새로운 sessionId를 발급받아 갱신하는 방향으로 수정했습니다~!!

Copy link
Member

@GIVEN53 GIVEN53 left a comment

Choose a reason for hiding this comment

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

빠른 반영 감사합니다 상돌 👍🏻 저도 빠르게 머지드리겠습니다
18시까지 부지런히 달려보죠!

@GIVEN53 GIVEN53 merged commit e9c7df5 into woowacourse:pricelees Sep 12, 2024
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.

3 participants