-
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
[톰캣 구현하기 1 & 2단계] 오션(김동해) 미션 제출합니다 #347
Merged
Merged
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b0af70d
test: File 경로 찾기 및 파일 내용 읽기 학습 테스트
e-astsea 201a25d
test: I/O Stream 학습 테스트
e-astsea 53f9a33
feat: GET /index.html 응답하기 추가
e-astsea 7afe7e6
feat: CSS 지원 기능 추가
e-astsea 0632809
docs: 요구사항 명세서 추가
e-astsea ce80cbd
feat: 파비콘 파일 추가
e-astsea 236a923
build: junit 추가
e-astsea 9a3e8af
feat: 쿼리 스트링 파싱 추가
e-astsea d59f30d
refactor: 1단계 코드 리팩토링
e-astsea cc51def
docs: 2단계 요구사항 추가
e-astsea 86fe3dc
feat: HTTP Status Code 302 기능 추가
e-astsea 30a4a30
feat: Post 방식 회원가입 및 Session 기능 추가
e-astsea b8e855c
refactor: 쿠키 파싱 로직 수정
e-astsea 634c64b
refactor: 절대 경로 조회 로직 수정
e-astsea 8616d73
refactor: 개행 수정
e-astsea e2232ed
refactor: BufferedReader HttpRequest 로직 수정
e-astsea 74a2e91
refactor: 존재하지 않는 리소스 404.html 리다이렉트
e-astsea 2b2ad1f
refactor: 로그인 세션 생성 로직 수정
e-astsea ed011fe
refactor: 코드 리팩토링
e-astsea 94de15d
refactor: findSession Optional 반환
e-astsea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
# 톰캣 구현하기 | ||
|
||
1단계 HTTP 서버 구현하기 | ||
-[x] HTTP 서버 구현하기 | ||
- [x] GET /index.html 응답하기 | ||
- [x] CSS 지원하기 | ||
- [x] Query String 파싱 | ||
|
||
2단계 로그인 구현하기 | ||
- [x] HTTP Status Code 302 | ||
- [x] 로그인 성공시 302반환 및 /index.html로 리다이렉트 | ||
- [x] 로그인 실패 시 401.html로 리다이렉트 | ||
- [x] POST 방식으로 회원가입 | ||
- [x] 회원가입 완료 시 index.html로 리다이렉트 | ||
- [x] 로그인 페이지도 POST 방식 | ||
- [x] Cookie에 JSESSIONID 값 저장 | ||
- [x] Session 구현 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tomcat/src/main/java/org/apache/catalina/session/Session.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.apache.catalina.session; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Session { | ||
private final String id; | ||
private final Map<String, Object> sessions; | ||
|
||
public Session(final String id) { | ||
this.id = id; | ||
this.sessions = new HashMap<>(); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Object getAttribute(final String name) { | ||
return sessions.get(name); | ||
} | ||
|
||
public void setAttribute(final String name, final Object value){ | ||
sessions.put(name,value); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tomcat/src/main/java/org/apache/catalina/session/SessionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.apache.catalina.session; | ||
|
||
import org.apache.catalina.Manager; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class SessionManager implements Manager { | ||
|
||
private static final Map<String, Session> SESSIONS = new HashMap<>(); | ||
|
||
@Override | ||
public void add(final Session session) { | ||
SESSIONS.put(session.getId(), session); | ||
} | ||
|
||
@Override | ||
public Session findSession(final String id) { | ||
if (SESSIONS.containsKey(id)) { | ||
return SESSIONS.get(id); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void remove(final Session session) { | ||
SESSIONS.remove(session.getId()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Optional 로 처리하는 방식도 좋을것 같아요!!😊
( 호출하는 쪽에서 세션이 없는 경우에 대해 어떻게 처리했는지에 대해 신경쓰지 않아도 되는 장점이 있을 것 같아요!! )
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.
Optional 로 처리하니 훨씬 깔끔하게 진행할 수 있게 된 것 같습니다! 수정하였습니다~