Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- tomcat
- CSS사용법
- Android Apk
- android fragment
- error
- FLUTTER
- android error
- release unsigned
- JavaScript
- R프로그래밍
- Firebase
- html
- DataTable
- Android Apk 이름
- MySQL
- spring
- fragment
- Android Apk 이름 변경
- java error
- Eclipse
- 안드로이드
- release Apk
- Program type already present
- css
- apache gzip
- Java
- Kotlin
- Android
- jQuery
- Exception
Archives
- Today
- Total
selfstarter
apache gzip filter 설정 본문
apach gzip filter 설정
apache gzip filter
apache gzip설정으로 전달 파일 압축 완료
http body에 parameter를 압축하여 전달할 수도 있다.
기본설정인 gzip 압축과 parameter 압축을 구분하기 위해 parameter 압축을 할 때 Content-Encoding을 gzip으로 설정한다
서버에서 filter에서 Content-Encoding 이 gzip인지 체크한다
parameter를 압축해서 받으면 압축된 상태이므로 압축을 해제해야한다. 이 때 request의 InputStream을 가져오면 request Buffer가 비게되므로 InputStream을 상속받는 request Wrapper class를 만들어서 압축해제한 데이터를 저장한다.
response도 Content-Encoding을 gzip으로 설정하기 위해 responseWrapper class 를 생성한다.
doFilter에 생성한 request, response 객체를 전달한다.
참고 사이트 : request 생성, response 생성
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; String acceptEncoding = httpRequest.getHeader(HttpHeaders.ACCEPT_ENCODING); String contentEncoding = httpRequest.getHeader(HttpHeaders.CONTENT_ENCODING); if (acceptEncoding.indexOf("gzip") >= 0 && contentEncoding.indexOf() >= 0) { // GZIPHttpServletRequestWrapper 생성자에서 압축 푼 데이터를 저장한다 GZIPHttpServletRequestWrapper gzipRequest = new GZIPHttpServletRequestWrapper(httpResponse); GZIPHttpServletResponseWrapper gzipResponse = new GZIPHttpServletResponseWrapper(httpResponse); chain.doFilter(gzipRequest, gzipResponse); gzipResponse.finish(); return; } chain.doFilter(request, response); }
'Server > Spring' 카테고리의 다른 글
Properties Some characters cannot be mapped using "ISO-8859-1" character encoding (0) | 2020.06.09 |
---|---|
Tomcat Error unknown version of Tomcat was specified (0) | 2020.05.15 |
apache gzip 설정 (0) | 2019.10.09 |
HttpServletRequest 모든 파라미터 가져오기 (0) | 2019.09.16 |
json list 안에 list 읽기 (0) | 2019.07.15 |
Comments