-
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단계] 재즈(함석명) 미션 제출합니다. (#581)
* fix: remove implementation logback-classic on gradle (#501) * fix: add threads min-spare configuration on properties (#502) * test: File 학습 테스트 * test: IOStream 학습 테스트 * feat: index.html 응답 기능 추가 * feat: ContentType Enum 정의 * feat: 요청 URI 확장자에 따라 ContentType을 동적으로 응답 * feat: 로그인 HTML 응답 기능 추가 * feat: 로그인 시 성공, 실패 여부에 따라 리다이렉트 처리 * feat: HTTP GET 메서드 조건을 추가 * feat: 로그인 요청을 GET에서 POST로 변경 * feat: 회원가입 HTML 응답 기능 추가 * feat: 회원가입 기능 추가 * refactor: 로그인 성공 로그 메시지 변경 * feat: 로그인 성공 시 JSESSIONID 쿠키를 반환하는 기능 추가 * feat: 세션 객체와 세션을 관리하는 세션 매니저 추가 * feat: 로그인 성공 시 세션 저장소에 유저 세션을 저장 * feat: 로그인 페이지 접근 시 이미 로그인 상태일 경우 리다이렉트 처리 * refactor: HttpMethod Enum 정의 * refactor: HttpStatus Enum 정의 * refactor: RequestLine 정의 * refactor: HttpRequest 정의 * feat: 휴리스틱 캐싱 제거 학습 테스트 추가 * feat: HTTP 응답 압축 학습 테스트 추가 * feat: ETag/If-None-Match 적용 학습 테스트 추가 * feat: 캐시 무효화 학습 테스트 추가 * refactor: RequestHeaders 구조 개선 * refactor: RequestLine에 HttpMethod를 물어보도록 개선 * refactor: 핸들러 분기 처리 개선 * move: ContentType 패키지 위치 이동 * refactor: HttpResponse 공백 추가 --------- Co-authored-by: Gyeongho Yang <[email protected]>
- Loading branch information
1 parent
0b698a2
commit 825fe18
Showing
31 changed files
with
1,022 additions
and
118 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
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
22 changes: 22 additions & 0 deletions
22
study/src/main/java/cache/com/example/cachecontrol/CacheControlInterceptor.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,22 @@ | ||
package cache.com.example.cachecontrol; | ||
|
||
import static com.google.common.net.HttpHeaders.CACHE_CONTROL; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import org.springframework.http.CacheControl; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
public class CacheControlInterceptor implements HandlerInterceptor { | ||
|
||
@Override | ||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { | ||
String cacheControl = CacheControl | ||
.noCache() | ||
.cachePrivate() | ||
.getHeaderValue(); | ||
|
||
response.setHeader(CACHE_CONTROL, cacheControl); | ||
return true; | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
study/src/main/java/cache/com/example/cachecontrol/WebMvcConfig.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,15 @@ | ||
package cache.com.example.cachecontrol; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebMvcConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
registry.addResourceHandler("/**") | ||
.addResourceLocations("classpath:/templates/", "classpath:/static/"); | ||
} | ||
} |
25 changes: 21 additions & 4 deletions
25
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,29 @@ | ||
package cache.com.example.etag; | ||
|
||
import static cache.com.example.version.CacheBustingWebConfig.PREFIX_STATIC_RESOURCES; | ||
|
||
import cache.com.example.version.ResourceVersion; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
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; | ||
// } | ||
private final ResourceVersion version; | ||
|
||
@Autowired | ||
public EtagFilterConfiguration(ResourceVersion version) { | ||
this.version = version; | ||
} | ||
|
||
@Bean | ||
public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() { | ||
FilterRegistrationBean<ShallowEtagHeaderFilter> filterRegistrationBean = new FilterRegistrationBean<>( | ||
new ShallowEtagHeaderFilter()); | ||
filterRegistrationBean.addUrlPatterns("/etag", PREFIX_STATIC_RESOURCES + "/" + version.getVersion() + "/*"); | ||
return filterRegistrationBean; | ||
} | ||
} |
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
3 changes: 1 addition & 2 deletions
3
study/src/main/java/cache/com/example/version/ResourceVersion.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
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
27 changes: 27 additions & 0 deletions
27
tomcat/src/main/java/org/apache/catalina/manager/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,27 @@ | ||
package org.apache.catalina.manager; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Session { | ||
|
||
private final String id; | ||
private final Map<String, Object> values; | ||
|
||
public Session(String id) { | ||
this.id = id; | ||
values = new HashMap<>(); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setAttribute(String name, Object value) { | ||
values.put(name, value); | ||
} | ||
|
||
public void removeAttribute(String name) { | ||
values.remove(name); | ||
} | ||
} |
Oops, something went wrong.