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단계 - HTTP 웹 서버 리팩토링 미션 제출합니다. #179

Open
wants to merge 18 commits into
base: chws
Choose a base branch
from

Conversation

chws
Copy link

@chws chws commented Oct 28, 2020

안녕하세요!
많은 지적 부탁드립니다:-)
감사합니다

chws and others added 18 commits October 28, 2020 16:10
- HttpSessionStorage.addSession에서 httpSession을 리턴하는 방식 수정
- HttpResponseHeaderParser에서 Set-Cookie에 Path 추가
- UserLogoutController 작성
- 추상 클래스 AuthController를 작성하여 세션을 가져오는 메소드 추가
- Set-Cookie 구현 방식 수정
Copy link

@jeonghoon1107 jeonghoon1107 left a comment

Choose a reason for hiding this comment

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

안녕하세요 레베카!
구현 잘 해주셨네요.
간단한 피드백을 남겼으니 확인해주세요.
중복되는 내용은 별도로 남기지 않았어요!

@Override
public HttpResponse get(HttpRequest httpRequest) {
try {
TemplateLoader loader = new ClassPathTemplateLoader();

Choose a reason for hiding this comment

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

template 부분과 비즈니스로직을 분리해보면 어떨까요?

public abstract class AuthController extends Controller {
protected HttpSession retrieveHttpSession(HttpRequest httpRequest) {
if (httpRequest.hasCookie("SESSIONID")) {
HttpSession httpSession = HttpSessionStorage.getSession(httpRequest.getSessionId());

Choose a reason for hiding this comment

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

getSession을 했을 때 존재하지 않으면 내부에서 만들어주면 어떨까요?

HttpSessionStorage를 controller까지 오픈할 필요는 없을 것 같아요.

boolean auth = userService.authenticateUser(httpRequest);
String header;
HttpSession httpSession;
Cookie cookie = new Cookie();

Choose a reason for hiding this comment

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

cookie 객체 생성을 내부로 감추면 어떨까요?

public class UserLogoutController extends AuthController {
@Override
public HttpResponse get(HttpRequest httpRequest) {
String header;

Choose a reason for hiding this comment

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

선언과 대입을 분리한 이유가 있나요?

public class HttpSessionStorage {
private static Map<String, HttpSession> storage = new HashMap<>();

public static HttpSession addSession(HttpSession httpSession) {

Choose a reason for hiding this comment

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

내부에서만 사용한다면 접근제어자를 수정하면 어떨까요?


import static org.assertj.core.api.Assertions.assertThat;

class CookieTest {

Choose a reason for hiding this comment

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

예외 케이스에 대한 테스트가 추가되면 좋을 것 같아요

}

public static String badRequest() {
return "HTTP/1.1 400 Bad Request \r\n" +

Choose a reason for hiding this comment

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

시스템 OS에 따라 개행이 달라질 수 있는데 System.lineSeparator()를 사용하면 어떨까요?

public boolean authenticateUser(HttpRequest httpRequest) {
String userId = httpRequest.getBodyValue("userId");
String password = httpRequest.getBodyValue("password");
User userById = DataBase.findUserById(userId);

Choose a reason for hiding this comment

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

Optional을 반환해도 좋을 것 같네요

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