-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[톰캣 구현하기 1, 2단계] 트레 미션 제출합니다. (#510)
* chore: .gitignore 학습 테스트를 버전 관리하지 않도록 수정 * feat: /index.html 응답하기 구현 * refactor: 200 응답 문자열 생성하는 부분을 메서드로 분리 * refactor: index.html 이외 다른 파일명이 들어와도 리소스 반환하도록 수정 * refactor: 메서드명 간결화 * feat: 리소스 존재하지 않는 경우 404.html 반환 * feat: Query String 파싱 구현 * fix: 올바른 Content-Type 지정 * fix: id, pw 존재하지 않아도 예외 발생하지 않도록 수정, /login으로 로그인 페이지 접속 가능하도록 수정 * refactor: Response Message를 생성하는 메서드에서 상태 코드를 인자로 받도록 수정 * feat: 로그인 시 리다이렉트 구현 * feat: 로그인을 POST 메서드로 변경 * feat: 회원가입 구현 * fix: .js 파일의 Content-Type 지정 * feat: HttpCookie 클래스 생성 * feat: Cookie에 JSESSIONID 값 저장하기 구현 * refactor: 상수 사용하도록 일부 수정 * fix: jakarta의 HttpSession을 사용하지 않도록 수정 * feat: 세션 구현 * refactor: Request 관련 로직을 별도의 클래스로 분리 * refactor: 헤더 읽기, body 읽기 로직을 메서드로 분리 * refactor: 쿠키 관련 로직을 분리 * refactor: HTTP 응답 로직 분리 * refactor: 메서드명 및 시그니처명 변경 * refactor: inline variable 적용 * refactor: 핸들러 메서드 분리 * refactor: 중복 제거 * refactor: 메서드명 변경 * refactor: 불필요한 if문 depth 제거 * chore: 패키지 구조 변경 * refactor: set-cookie 하는 부분 메서드 분리 * fix: Location 헤더로 올바르게 리다이렉션 하도록 수정 * refactor: 메서드명 수정 * fix: request line 마지막에 공백 추가 * refactor: 단순 텍스트를 응답하는 경우에 대한 응답 메서드 작성 * test: 깨지는 테스트 수정 * refactor: 메서드명 변경 * feat: 존재하지 않는 리소스에 접근하는 경우 404 페이지를 보여줌 * refactor: Location 헤더를 enum으로 관리 * chore: print문 삭제 * refactor: Set-Cookie 헤더를 상수가 아닌 enum으로 변경 * test: FileTest 작성 * test: IOStreamTest 작성 * chore: 학습 테스트를 다시 버전관리 하도록 수정 * fix: remove implementation logback-classic on gradle (#501) (cherry picked from commit fed02f6) * fix: add threads min-spare configuration on properties (#502) (cherry picked from commit 7e91356) * chore: Thymeleaf 의존성 추가 * feat: 휴리스틱 캐싱 제거 * chore: HTTP 압축 설정 * feat: ETag 추가 * feat: .js와 .css 파일은 1년 동안 캐시 적용 * refactor: interceptor 구현체를 지우고 WebContentIntercepor 사용 * refactor: 헤더의 이름을 enum에서 꺼내오도록 수정 * refactor: 미사용 메서드 제거 * refactor: depth 개선 * refactor: request에서 cookie 가져오는 로직 메서드로 분리 * refactor: HttpCookie에 세션 관련 메서드 생성 * refactor: Set-Cookie 관련 로직 개선 * refactor: if문 개선 * refactor: HttpHeaders -> HttpHeaderType * refactor: 반복문을 스트림으로 개선 * refactor: 각종 delimiters 상수화 * refactor: 중복되는 build() 로직 개선 * refactor: CRLF 상수화
- Loading branch information
1 parent
0b698a2
commit 28e85b8
Showing
29 changed files
with
999 additions
and
99 deletions.
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
13 changes: 13 additions & 0 deletions
13
study/src/main/java/cache/com/example/cachecontrol/CacheWebConfig.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 |
---|---|---|
@@ -1,13 +1,26 @@ | ||
package cache.com.example.cachecontrol; | ||
|
||
import static java.util.concurrent.TimeUnit.DAYS; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.CacheControl; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
import org.springframework.web.servlet.mvc.WebContentInterceptor; | ||
|
||
@Configuration | ||
public class CacheWebConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addInterceptors(final InterceptorRegistry registry) { | ||
WebContentInterceptor noCacheIntercepter = new WebContentInterceptor(); | ||
noCacheIntercepter.addCacheMapping(CacheControl.noCache().cachePrivate(), "/**"); | ||
registry.addInterceptor(noCacheIntercepter) | ||
.excludePathPatterns("/**/*.js", "/**/*.css"); | ||
|
||
WebContentInterceptor cacheIntercepter = new WebContentInterceptor(); | ||
cacheIntercepter.addCacheMapping(CacheControl.maxAge(365, DAYS).cachePublic(), "/**"); | ||
registry.addInterceptor(cacheIntercepter) | ||
.addPathPatterns("/**/*.js", "/**/*.css"); | ||
} | ||
} |
14 changes: 10 additions & 4 deletions
14
study/src/main/java/cache/com/example/etag/EtagFilterConfiguration.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 |
---|---|---|
@@ -1,12 +1,18 @@ | ||
package cache.com.example.etag; | ||
|
||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.filter.ShallowEtagHeaderFilter; | ||
|
||
@Configuration | ||
public class EtagFilterConfiguration { | ||
|
||
// @Bean | ||
// public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() { | ||
// return null; | ||
// } | ||
@Bean | ||
public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() { | ||
FilterRegistrationBean<ShallowEtagHeaderFilter> filter | ||
= new FilterRegistrationBean<>(new ShallowEtagHeaderFilter()); | ||
filter.addUrlPatterns("/etag", "*.js", "*.css"); | ||
return filter; | ||
} | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
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,21 @@ | ||
package org.apache.catalina.session; | ||
|
||
import com.techcourse.model.User; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Session { | ||
|
||
private static final String USER_SESSION_NAME = "user"; | ||
|
||
private final Map<String, Object> values = new HashMap<>(); | ||
|
||
private Session() { | ||
} | ||
|
||
public static Session ofUser(User user) { | ||
Session session = new Session(); | ||
session.values.put(USER_SESSION_NAME, user); | ||
return session; | ||
} | ||
} |
Oops, something went wrong.